Cheatography
https://cheatography.com
Different ways to change the color of text in bash scripts
TPUT Control Codessetf | Foreground color (text) | setaf | Foreground color (ANSI escaped) | setb | Background color | setab | Background color (ANSI escaped) | bold | Brighten all colors | dim | Darken all colors | rev | Reverse color pallete | smul | Begin underlining | rmul | Stop underlining | smso | Enter Standout Mode | rmso | Exit Standout Mode | smcup | Clear | clear | Clear | reset | Reset Screen Size | rmcup | Restore | sgr0 | Revert all attribute changes |
Usage: tput <control> [color]
Red Hello:
tput setaf 1;echo "Hello";tput sgr0
Light Green ps:
tput setaf 2;tput bold;ps;tput sgr0
TPUT Color CodesBlack | 0 | Red | 1 | Green | 2 | Yellow | 3 | Blue | 4 | Magenta | 5 | Cyan | 6 | Light Grey | 7 |
| | LS_COLORS File CodesBlock Device (buffered) | bd | File with Capability | ca | Character Device (unbuffered) | cd | Directory | di | Door | do | End Code | ec | Executable File | ex | File | fi | Left Code | lc | Symbolic Link | ln | Multi Hard Link (File with more than one link) | mh | Missing File (Pointed to by a symlink) | mi | Orphaned Symbolic Link (Points to a missing file) | or | Other-Writable Directory | ow | Named Pipe | pi | Right Code | rc | Socket File | so | Directory Sticky (+t) | st | File setuid (u+s) | su | Sticky AND Other-Writable | tw | File Extension Specific | *.example | | .example |
Create a dircolors file with dircolors -p > ~/.dircolors see dir_colors(1), dir_colors(5) for more info
| | ANSI Control CodesReset | 0 | Bold | 1 | Dim | 2 | Underline on | 4 | Underline off | 24 | Blink start | 5 | Blink end | 25 | Inverse pallete start | 7 | Inverse pallete end | 27 | Conceal | 8 | Normal | 22 |
see console_codes(4) for more information
ANSI Color CodesColor | Text | Background | Black | 30 | 40 | Red | 31 | 41 | Green | 32 | 42 | Yellow | 33 | 43 | Blue | 34 | 44 | Magenta | 35 | 45 | Cyan | 36 | 46 | Light Grey | 37 | 47 |
|
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets