This bash script will give you a custom bash prompt that has colors that are switchable on the fly.
PS1=$( sep=$'\xC2\xBB' # UTF-8 U+00BB red=$(tput setaf 1) green=$(tput setaf 2) yellow=$(tput setaf 3) blue=$(tput setaf 4) cyan=$(tput setaf 5) bold=$(tput bold) reset=$(tput sgr0) [[ $EUID -eq 0 ]] && user=$red || user=$green echo "\[$user\]\u@\h\[$reset\] \[$blue$bold\]$sep\[$reset\] \[$yellow\]\W\[$reset\] \[$blue$bold\]$sep\[$reset\] \[$user\]\$\[$reset\] " ) |
To change to a green prompt, use this command.
jason@jason-desktop:~$ tput setaf 2 |
And this one for a blue shell prompt.
jason@jason-desktop:~$ tput setaf 5 |
This is a very cool idea, this means that the color of the shell prompt may be changed whenever you wish. This is a nice way to customize the shell prompt. I guess other settings could be controlled this way too.
Run this command to print all available colors in your terminal.
for i in {17..255};{ printf '\e[38;5;%dm%d \n' "$i" "$i"; } | column |