Helpful BASH Shell Command Prompts

July 28, 2007

Here are some helpful tips on altering your BASH command prompt. Info in your command prompt can improve your work productivity and also prevent you from doing the wrong thing at the wrong place.

Add one of the below entries into your .bashrc file

vi ~/.bashrc

then activate your changes by sourcing it

source ~/.bashrc

1) To display the username, short version of hostname, and the current working directory (light blue)

export PS1='\[\033[1;34m\][\u@\h:\w]\$\[\033[0m\]'



2) To display username, short version of hostname, date, time, and the current working directory

export PS1='[\u@\h \d \A] \w \$ '


[phil@server1 Sat Jul 28 15:44] /usr/local/lib $

3) To display new line, username, short version hostname, base PTY, shell level, history number, new line, and the current working directory

export PS1='\n[\u@\h \l:$SHLVL:\!]\n$PWD\$ '


[phil@server1 0:1:123]

4) To display, username, short version hostname, number of jobs in the background a new line and working path

export PS1='\n[\u@\h jobs:\j]\n$PWD\$ '


[phil@server1 jobs:0]

Comments are closed.