Skip to content

Instantly share code, notes, and snippets.

@crazy2be
Created September 22, 2015 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crazy2be/a9b85d9d17040c85584e to your computer and use it in GitHub Desktop.
Save crazy2be/a9b85d9d17040c85584e to your computer and use it in GitHub Desktop.
Add to .bash_profile to get more useful terminal titles.
# http://askubuntu.com/questions/126737/make-gnome-terminal-show-the-command-running-as-title
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
prompt_prefix()
{
if [ "$USER" != "jmcgirr" ] || [ "$HOSTNAME" != "jmcgirr-ld1" ]; then
echo -n "${USER}@${HOSTNAME}: "
else
echo -n
fi
}
PROMPT_COMMAND='echo -ne "\033]0;᚛$(prompt_prefix)$(basename "$PWD")\007"'
# Show the currently running command in the terminal title:
# http://www.davidpashley.com/articles/xterm-titles-with-bash.html
show_command_in_title_bar()
{
case "$BASH_COMMAND" in
*\033]0*)
# The command is trying to set the title bar as well;
# this is most likely the execution of $PROMPT_COMMAND.
# In any case nested escapes confuse the terminal, so don't
# output them.
;;
*)
echo -ne "\033]0;☀$(prompt_prefix)${BASH_COMMAND}\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