Improve titlebar content

Shows entire previous command, followed by '- Alacritty ($host)'
This commit is contained in:
John Mertz 2024-01-30 20:25:33 -07:00
parent db2b6142a2
commit f9e688dac0
1 changed files with 11 additions and 3 deletions

View File

@ -52,10 +52,18 @@ if ! shopt -oq posix; then
fi
fi
if [[ -z $TERM_TITLE ]]; then
TERM_TITLE="$TERM";
fi
# Set window title to last command
PROMPT_COMMAND='echo -e -n "\033]2;$_\007"'
# Reconfigure prompt after each return
PROMPT_COMMAND="$PROMPT_COMMAND; source ${HOME}/.dotfiles/bash/prompt.sh"
function last_command {
local h="$(history 1)";
echo "${h##*([[:space:])+([[:digit:]])+([[:space:]])}"
}
PS0='\[\e]0;$(last_command) - $TERM_TITLE\a\]'
# Update prompt
PROMPT_COMMAND="source ${HOME}/.dotfiles/bash/prompt.sh"
# Bell when prompt is returned to mark as urgent
PROMPT_COMMAND="$PROMPT_COMMAND;printf \"\a\"; history -a"