BASH Red prompt
2022 edit – this needs revisiting – do not repeat! The code bellow breaks the prompt!
OK, so this is mainly for personal use.
When logging via SSH to a certain server it’s always a good idea to have custom prompt colours. I personally set staging environment to be yellow and production – red.
So in order to change this – you edit the .bashrc file in your home directory
$ vi ~/.bashrc
Then you need to find the following section:
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
If it exists – you need to replace the first section with one of the following. If not – you just paste it on the bottom of the file.
Red:
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
Yellow:
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;33m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
This is currently working as a charm under Ubuntu server 18.