Seems like nowadays everyone has his or her own shell prompt, one even fancier than the other. After being to several conferences I though it was time to start customising my own shell prompt too. Being a big fan of Bash, there’s already a lot written about custom prompts and what elements are all there so I’m gonna refrain from that. I’m just going to include my own shell prompt and its variables for a short explanation.
So the prompt is pretty straight-forward, fist showing the time in blue using [033[38;5;45m]\A
Then showing the current user in green using [033[01;33m]\u
Followed by a white ‘@’ symbol using [033[39m]@
Then the hostname in yellow using [033[01;31m]\h
Followed by 3 white ‘>’ symbols using [033[00m]>>>
Followed by a space and then the working directory in red brackets using [033[01;31m][\W]
And finally the well known $ sign in white using [033[00m] $
Setting the prompt can be done quite easily by modifying the .bashrc file to include the following line which includes all the required escapes:
PS1='\[\033[01;34m\]\A \[\033[01;92m\]\u\[\033[01;39m\]@\[\033[01;33m\]\h\[\033[00m\] >>> \[\033[01;31m\][\W]\[\033[00m\] $ '
Of course this can also be set or edited temporarily by using the export command