Skip to content

Instantly share code, notes, and snippets.

@third774
Created August 27, 2017 14:07
Show Gist options
  • Save third774/31c831d22835f21d0233e31bbd0f01dc to your computer and use it in GitHub Desktop.
Save third774/31c831d22835f21d0233e31bbd0f01dc to your computer and use it in GitHub Desktop.
Adding this to .bash_profile updates the tab title when the directory changes
# Adding this to .bash_profile updates the tab title when the directory changes
# can also manually name a tab eg: title FOOBAR
function title {
export TITLE_OVERRIDDEN=1
PROMPT_COMMAND=''
echo -ne "\033]0;"$*"\007"
}
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND='echo -ne "\033]0;${PWD##*/}\007"'
show_command_in_title_bar()
{
if [[ "$TITLE_OVERRIDDEN" == 1 ]]; then return; fi
case "$BASH_COMMAND" in
*\033]0*)
;;
*)
echo -ne "\033]0;${BASH_COMMAND} - ${PWD##*/}\007"
;;
esac
}
trap show_command_in_title_bar DEBUG
;;
*)
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment