Preferred Linux prompt

From Julian Yap

These are my preferred settings when setting a Linux Bash prompt.

In ~/.bashrc or ~/.bash_profile

if [ "$TERM" = "linux" ]
then
        #we're on the system console or maybe telnetting in
        #just modify the prompt
        export PS1="[\u@\h \W]\$ "
else
        #we're not on the console, assume an xterm
        export PS1="\[\e]2;\u@\H \w\a[\u@\h \W]\$ "
fi

This sets the title bar as:

[username]@[full hostname] [current working directory]

Sets the prompt as:

[username]@[hostname] ["basename" of current working directory ]

Tips from Prompt Magic article.