pub const BASH: &str = r#"
_forge_cmd_running=
_forge_in_prompt=
_forge_status=0
_forge_prompt() {
local ret=$_forge_status
if [ -n "$_forge_cmd_running" ]; then
printf '\033]133;D;%s\007' "$ret"
_forge_cmd_running=
fi
printf '\033]133;A\007\033]133;B\007'
_forge_in_prompt=1
}
_forge_preexec() {
_forge_status=$?
if [ -n "$_forge_in_prompt" ]; then
return 0
fi
case "$BASH_COMMAND" in
_forge_prompt) return 0 ;;
esac
if [ -z "$_forge_cmd_running" ]; then
_forge_cmd_running=1
printf '\033]133;C\007'
fi
return 0
}
PROMPT_COMMAND="_forge_prompt${PROMPT_COMMAND:+;$PROMPT_COMMAND};_forge_in_prompt="
trap '_forge_preexec' DEBUG
"#;Expand description
The bash integration: PROMPT_COMMAND closes the previous command and
opens the prompt, a DEBUG trap opens the command.
Bash 3.2 (macOS) has no PS0, so the trap is the only pre-exec hook, and
it fires for the prompt’s own commands too. Two guards keep the marks
honest: the trap hands $? back so _forge_prompt reads the command’s
real status, and _forge_in_prompt plus the $BASH_COMMAND match keep the
prompt’s commands from being announced as the person’s.