Main menu

Post navigation

Bash: different colors for typed command and its output

There are lots of examples showing how to set a nice colorful bash prompt. I wanted more than the output: the typed text should be hi-intensity, but the command output should be normal. I found only a hackish solution:

Install a DEBUG trap in your ~/.bashrc:

trap 'echo -ne "\e[0m" > $(tty)' DEBUG

And add yourself to the tty group:

sudo adduser <username> tty

It works, although I still have to think what can it break at some moment (long after I completely forget about that .bashrc line):