pub const FISH_HOOK: &str = r#"
# rec shell hooks for Fish
# Add to ~/.config/fish/config.fish: rec init fish | source
# Shell wrapper: automatically manages REC_RECORDING for start/stop
function rec --wraps=rec
if test (count $argv) -ge 1; and test "$argv[1]" = "start"
command rec $argv; and set -gx REC_RECORDING 1
else if test (count $argv) -ge 1; and test "$argv[1]" = "stop"
command rec $argv; and set -e REC_RECORDING
else
command rec $argv
end
end
# Capture command before execution
# Note: $argv is the verbatim command line (aliases NOT expanded)
function __rec_preexec --on-event fish_preexec
if set -q REC_RECORDING
rec _hook preexec "$argv" 2>/dev/null; or true
end
end
# Capture exit code after command completes
function __rec_postexec --on-event fish_postexec
set -l exit_code $status
if set -q REC_RECORDING
rec _hook precmd "$exit_code" 2>/dev/null; or true
end
end
# Recording indicator for prompt
# Call this from your fish_prompt function if you want the indicator
function __rec_prompt_indicator
if set -q REC_RECORDING; and not set -q REC_NO_PROMPT
set_color red
echo -n "● "
set_color normal
end
end
# Fish doesn't allow dynamic prompt modification like Bash/Zsh
# Users should add __rec_prompt_indicator to their fish_prompt function
# Or we provide a wrapper (below) that they can use
# Optional: Wrap existing fish_prompt to add indicator
# Uncomment if you want automatic prompt modification:
# functions -c fish_prompt __rec_original_fish_prompt 2>/dev/null
# function fish_prompt
# __rec_prompt_indicator
# __rec_original_fish_prompt
# end
"#;Expand description
Fish hook script.
Uses native Fish event handlers. Note: Fish does NOT expand aliases
in fish_preexec - the command line is passed verbatim.