ANSI Colors
Published on 17 July, 2013 by amjANSI Color Tables:
Reference: https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
Color Attribute | Foreground Value | Background Value |
---|---|---|
Black | 30 | 40 |
Red | 31 | 41 |
Green | 32 | 42 |
Yellow | 33 | 43 |
Blue | 34 | 44 |
Magenta | 35 | 45 |
Cyan | 36 | 46 |
White | 37 | 47 |
Text Attribute | Value |
---|---|
None | 0 |
High Intensity (bold) | 1 |
Underline (monochrome display only) | 4 |
Blink | 5 |
Reverse | 7 |
Invisible | 8 |
This:
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;33m\]\u\[\033[0m\]@\[\033[01;32m\]\h\[\033[0m\]:\w\$
equals—essentially—this:user@localhost:~$
Other uses:
#!/bin/bash
thishost=$HOSTNAME
cd $HOME
printf "\33[1;33mThis is a great song\33[0m\33[1m:\33[0m \33[1;34mEternal Nightmare -- Little Copy\33[0m \33[1m--amj\33[0m\n\n"
sudo -nv 2> /dev/null
if [ $? = 1 ]; then
printf "\33[1;33mPlease enter your password\nto run updates for\33[0m \33[1;32m$thishost\33[0m.\n\n"
fi
sudo apt-get update
printf "\n\33[1;32m$thishost\33[1;33m is currently running kernel version\33[0m\33[1m:\33[34m "; uname -r
printf "\33[0m\n"
sudo apt-get dist-upgrade
cd -
See also:Tweaks And That Sort Of Jive