Skip to content

Shell Integration

Automatically save every command with metadata for better recall and context.

Setup

Install the shell hook:

aethr hook --install

This adds the hook to your ~/.bashrc or ~/.zshrc.

Restart your shell or source the config:

source ~/.bashrc  # or ~/.zshrc

What Gets Captured

The hook saves each command with:

Field Description
command The command you ran
exit_code Success (0) or failure code
duration_ms How long it took
working_dir Where you ran it
timestamp When you ran it

How It Works

Uses PROMPT_COMMAND to capture the last command after each prompt:

PROMPT_COMMAND='aethr hook bash'

Uses precmd and preexec hooks:

preexec() { ... }
precmd() { aethr hook zsh }

Commands are logged to ~/.aethr/commands.log and processed on the next Aethr invocation.

Manual Hook Script

If you prefer manual setup, add this to your shell config:

# Aethr shell hook
_aethr_last_cmd=""
_aethr_start_time=""

_aethr_preexec() {
    _aethr_last_cmd="$1"
    _aethr_start_time=$(date +%s%3N)
}

_aethr_precmd() {
    local exit_code=$?
    if [ -n "$_aethr_last_cmd" ]; then
        local end_time=$(date +%s%3N)
        local duration=$((end_time - _aethr_start_time))
        echo "$_aethr_last_cmd|$exit_code|$duration|$(pwd)|$(date +%s)" >> ~/.aethr/commands.log
        _aethr_last_cmd=""
    fi
}

trap '_aethr_preexec "$BASH_COMMAND"' DEBUG
PROMPT_COMMAND="_aethr_precmd${PROMPT_COMMAND:+;$PROMPT_COMMAND}"
# Aethr shell hook
_aethr_last_cmd=""
_aethr_start_time=""

preexec() {
    _aethr_last_cmd="$1"
    _aethr_start_time=$(date +%s%3N)
}

precmd() {
    local exit_code=$?
    if [[ -n "$_aethr_last_cmd" ]]; then
        local end_time=$(date +%s%3N)
        local duration=$((end_time - _aethr_start_time))
        echo "$_aethr_last_cmd|$exit_code|$duration|$(pwd)|$(date +%s)" >> ~/.aethr/commands.log
        _aethr_last_cmd=""
    fi
}

Verify

After setup, run a few commands then check:

aethr status

You should see the command count increase.

Disable Auto-Save

To disable without removing the hook:

# In ~/.aethr/config.yaml
auto_save: false

Or remove the hook from your shell config and restart.

Privacy Note

Commands are stored locally in ~/.aethr/commands.log and ~/.aethr/aethr.db. Nothing is sent anywhere unless you explicitly enable sharing.