Shell Integration
Claudette can track terminal commands and display them in the sidebar with status indicators (running, success, failure). This is optional and requires adding a small snippet to your shell’s RC file.
How It Works
Section titled “How It Works”When Claudette opens a terminal, it sets the CLAUDETTE_PTY environment variable. The shell integration snippet uses OSC 133 escape sequences to communicate command boundaries back to Claudette, enabling:
- Command start/end detection
- Exit code tracking
- Command text capture
- Real-time status indicators in the sidebar
Add the appropriate snippet to your shell’s RC file.
Add to ~/.zshrc:
# Claudette shell integrationif [[ -n "$CLAUDETTE_PTY" ]]; then _claudette_precmd() { local exit_code=$? printf '\033]133;D;%s\007' "$exit_code" printf '\033]133;A\007' return $exit_code }
_claudette_preexec() { printf '\033]133;B\007' local cmd_encoded=$(printf '%s' "$1" | jq -sRr @uri 2>/dev/null || printf '%s' "$1" | od -An -tx1 | tr ' ' '%' | tr -d '\n') if [[ -n "$cmd_encoded" ]]; then printf '\033]133;E;%s\007' "$cmd_encoded" fi printf '\033]133;C\007' }
autoload -Uz add-zsh-hook add-zsh-hook precmd _claudette_precmd add-zsh-hook preexec _claudette_preexecfiAdd to ~/.bashrc:
# Claudette shell integrationif [[ -n "$CLAUDETTE_PTY" ]]; then _claudette_prompt_start() { printf '\033]133;A\007' }
_claudette_prompt_cmd() { local exit_code=$? printf '\033]133;D;%s\007' "$exit_code" _claudette_prompt_start return $exit_code }
_claudette_preexec() { printf '\033]133;B\007' local cmd_encoded=$(printf '%s' "$BASH_COMMAND" | jq -sRr @uri 2>/dev/null || echo "") if [[ -n "$cmd_encoded" ]]; then printf '\033]133;E;%s\007' "$cmd_encoded" fi printf '\033]133;C\007' }
PROMPT_COMMAND="_claudette_prompt_cmd" trap '_claudette_preexec' DEBUGfiAdd to ~/.config/fish/config.fish:
# Claudette shell integrationif test -n "$CLAUDETTE_PTY" function __claudette_prompt_start --on-event fish_prompt printf '\033]133;A\007' end
function __claudette_preexec --on-event fish_preexec printf '\033]133;B\007' set cmd (string join ' ' $argv) set cmd_encoded (string escape --style=url -- $cmd) if test -n "$cmd_encoded" printf '\033]133;E;%s\007' "$cmd_encoded" end printf '\033]133;C\007' end
function __claudette_postexec --on-event fish_postexec printf '\033]133;D;%s\007' $status endendActivating
Section titled “Activating”After adding the snippet, restart your terminal or source the RC file:
# Zshsource ~/.zshrc
# Bashsource ~/.bashrc
# Fishsource ~/.config/fish/config.fishCommands will now appear in the sidebar with status indicators:
- Running — command is currently executing
- Success — command exited with code 0
- Failure — command exited with a non-zero code
- The integration only activates inside Claudette terminals (when
CLAUDETTE_PTYis set) - It does not affect your shell behavior outside of Claudette
- The
jqcommand is used for URL-encoding command text; ifjqis not installed, a fallback encoding is used