Re:Util-linux cheat sheet
by derleth on Saturday September 08, 2012 @04:26PM
(#4493891)
Almost forgot: Under xterm, at least, ^V is the escape character and ^[ is ESC, so you can type things like:
$ echo '^[[0m^[[01;32mfoo^[[0m'
with a ^V before every ^[ (the ^V doesn't get echoed back to you unless you type ^V^V to enter a single ^V). That makes 'foo' bold and lime green.
Once you learn how to read a terminfo file, you can do everything your terminal is capable of (and xterm can do quite a bit) entirely by typing control codes by hand. Which is pointless, given that tput, from the ncurses package, does the same thing in a much more user-friendly way that's also completely terminal-independent.
$ echo '^[[0m^[[01;32mfoo^[[0m'
with a ^V before every ^[ (the ^V doesn't get echoed back to you unless you type ^V^V to enter a single ^V). That makes 'foo' bold and lime green.
Once you learn how to read a terminfo file, you can do everything your terminal is capable of (and xterm can do quite a bit) entirely by typing control codes by hand. Which is pointless, given that tput, from the ncurses package, does the same thing in a much more user-friendly way that's also completely terminal-independent.
http://en.wikipedia.org/wiki/Ncurses
http://www.gnu.org/software/ncurses/ncurses.html
http://en.wikipedia.org/wiki/Tput
http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x405.html -- Explicitly about using tput, which really is a neat way to make your shell script's output look nice.