Name terminal windows from inside them
Found myself with some rare free time, queuing up some small posts. Here’s a bash function I’ve been using for about a year now to name terminal windows. This is helpful to organize the 10-20 terminals I might have open at any given time across many virtual desktops. Unlike some tricks, I actually use it all the time so I figure that’s one person that finds it useful… so here it is in case someone else might also find it useful.
From .bashrc, it is very simple:
function n() {
if [ "X" = "X$1" ]; then
echo "give at least one parameter for window name"
return 1
fi
NAME="$*"
PROMPT_COMMAND='echo -ne "\033]0;$NAME\007"'
export PROMPT_COMMAND
return 0
}
Nothing to it… just names the current terminal window.
$ n CLUSTER 3 $ ssh tfreeman@cluster3...
I like CAPS usually and I set my title bar font all big:

This overrides the default setting which was to print the current directory. Here’s how to do that…
PROMPT_COMMAND='echo -ne "\033]0;${PWD/$HOME/~}\007"'
