Skip to content

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.

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:

Terminal window
# Claudette shell integration
if [[ -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_preexec
fi

After adding the snippet, restart your terminal or source the RC file:

Terminal window
# Zsh
source ~/.zshrc
# Bash
source ~/.bashrc
# Fish
source ~/.config/fish/config.fish

Commands 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_PTY is set)
  • It does not affect your shell behavior outside of Claudette
  • The jq command is used for URL-encoding command text; if jq is not installed, a fallback encoding is used