The bash prompt is the first thing you see when you log into a *nix machine.
Customizing you bash prompt is easy, very useful and ofcourse, cool. Here are some tips n tricks. The prompt of your bash shell can be changed by altering the PS1 shell variable. To try out shell modifications you can directly do this, try the code below
Code:
PS1="hey there! #"
causing your prompt to be displayed as,
Code:
hey there ! #
Now thats cool, but it ain't useful yet. You can make your prompt useful by using certain escape sequences which are replaced by useful values. Example -
Code:
u - Username
h - Hostname
w - The current working directory with complete path.
W - The current working directory.
d - Current date.
t - Time.
Setting the value of PS1 at the prompt will only be temporary and the next time you run bash, the changes won't be seen. For permanent changes, you must add the PS1 statements into .bashrc or any of the startup scripts that bash processes. Here are some useful prompts that might be of use -
Code:
PS1="[u@h w]"
PS1="[u@h W]"
PS1="d t W >"
PS1="w $"