iEntry 10th Anniversary LinuxHaxor WH MH

Making Dynamic Bash Prompt


Special character sequences in the prompt let you include the current directory, date and time, username, hostname, and much more. Your can get more information about this on your shell manual and depending on the shell type it should list these as PS1 or prompt variable.

It’s simplest to put single quotes around the prompt string to prevent interpretation as the prompt is stored. For example, the following prompt shows the date and time, separated by spaces. It also has a special sequence at the end (\$ in bash, %# in tcsh and zsh) that’s printed as a hash mark (#) if you’re the superuser, or the usual prompt character for that shell otherwise.

PS1=’\d \t \$ ‘ for bash

set prompt=’%w %D %Y %P %# ‘ for tcsh

PS1=’%W %* %# ‘ for zsh

2007-12-20-021420_1280x800_scrot

From here on you can let your imagination go wild and use a blank promt (which can be devilishly snicky ;) )
However one of my personal favorite is PS1=”===>”

2007-12-20-023252_1280x800_scrot

Obviously these are not permanent and will go away as soon as you log out from the terminal.


Comments are closed.