Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zach-is-my-name/235e4af84ab546e1635120b1fc49a5dc to your computer and use it in GitHub Desktop.
Save zach-is-my-name/235e4af84ab546e1635120b1fc49a5dc to your computer and use it in GitHub Desktop.
_prompt_executing=""
function __prompt_precmd() {
local ret="$?"
if [[ "$_prompt_executing" != "1" ]]; then
_PROMPT_SAVE_PS1="$PS1"
_PROMPT_SAVE_PS2="$PS2"
PS1=$'%{\e]133;P;k=i\a%}'$PS1$'%{\e]133;B\a\e]122;> \a%}'
PS2=$'%{\e]133;P;k=s\a%}'$PS2$'%{\e]133;B\a%}'
fi
if [[ -n "$_prompt_executing" ]]; then
printf "\033]133;D;%s;aid=%s\007" "$ret" "$$"
fi
printf "\033]133;A;cl=m;aid=%s\007" "$$"
_prompt_executing=0
}
function __prompt_preexec() {
PS1="$_PROMPT_SAVE_PS1"
PS2="$_PROMPT_SAVE_PS2"
printf "\033]133;C;\007"
_prompt_executing=1
}
preexec_functions+=(__prompt_preexec)
precmd_functions+=(__prompt_precmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment