Linux Prompt

This post describes how to automatically change window title of you session (also in Putty) whenever you log in to your server.

Add following code to /etc/profile on your server to enable automatic change of title (prompt) of your console when you connect to a server, this will be changed back to previous value when you will log off.

if [ "$TERM" = "xterm" ] ; then
export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
else
unset PROMPT_COMMAND
fi

This will change the window title to:

user@host: ~

Share on TwitterShare on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit