Most Unix shells let you customize the command prompt. The traditional prompt is just a $ or #, for normal users or the root user, respectively. A short prompt made sense when using Teletype terminals at 110 bit/s, or 10 characters/second, when a longer prompt might have taken a second or two to print.

These days, the length of a prompt is no longer a speed issue, and you can even get colours. This article gives a taste of the possibilities, for the Bash shell. For other shells, look into their documentation. The Zsh shell is especially powerful in this area.

In the Bash shell, you change the prompt by setting the PS1 variable to the value you want. You can use various escape sequences for dynamic content. For example:

\h     the hostname up to the first `.'
\t     the current time in 24-hour HH:MM:SS format
\w     the  current  working  directory,  with $HOME
       abbreviated with a tilde

See the bash manual page for the full list (search for "PROMPTING").

As an example, set PS1 like this:

PS1='\u@\h:\w\$ '

After this, the prompt will look something like this:

liw@exolobe1:~/.../yakking.branchable.com$ 

Here, \u will be expanded to the user running the shell, \h to the hostname, \w to the current working directory (with some shortening logic, as shown above), and \$ to either $ or # depending on whether the user is root or not.

You can also set the prompt even more dynamically, by setting the PROMPT_COMMAND variable. Bash will evaluate the contents of that variable as shell commands, and those commands can, for example, set PS1 to contain the currently checked out branch of a git repository. (Doing that is left as a tantalising exercise to the reader.)