Bash – Customizing bash shell: Bold/color the command

bashcolors

There are a number of tutorials/posts online (e.g. http://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/) about how to customize your prompt in bash by setting PS1. Is there a way to customize the color/bolding of the command I type?

In other words, as an example lets say that I wanted a green prompt, a bold blue command, and then output in whatever colors would be default. In the example below, I already know how to make "joe>" show as green, blue, bold, whatever by setting PS1. But is there a way I can I make git status show as bold for example?

joe> git status
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
#
...

Best Answer

You'd have to leave a colour trailing after the PS1 (start it after > in your example), and then use the bash DEBUG trap to clear the colour before your command was run (but after you press enter in your shell. Try something like this:

shopt -s extdebug
trap "tput sgr0" DEBUG
Related Question