Trix & Graphix

Customizing the Unix prompt

This is a very fast post about the prompt (basically this is an auto-remainder for myself xD).


The appearance of the prompt in an Unix terminal is determined by the environment variable PS1. You can (you have to) modify it if you want to change the prompt. It is easy to take a look at the current value of variable: just type in an open terminal
echo $PS1
and here is it. The prompt that I'm currently using is this one:
PS1='$(tput setaf 1)\u@\h $(tput setaf 2)\w> $(tput setaf 0)'
There are a number of commands very useful to depict important information. In my example \h shows the name of the host, whereas \u is the user and \w is the current working path. The commands tput setaf change the color. Take a look to the man pages of tput and terminfo to learn more.

Of course there are many more options. Here there is a more complete reference in this respect. By the way, it is a good idea to modify this variable in the .bash_profile file in your home directory :)

0 Comments: