From f9e688dac035a1c74f857548c955fa20d35ca54f Mon Sep 17 00:00:00 2001 From: John Mertz Date: Tue, 30 Jan 2024 20:25:33 -0700 Subject: [PATCH] Improve titlebar content Shows entire previous command, followed by '- Alacritty ($host)' --- bash/bashrc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bash/bashrc b/bash/bashrc index 6212c15d7..7d0e23e12 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -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"