I know how to change the font color via preferences, but it changes the color of ALL text, as in below:
What I'm going for is something more like this:
Any tips?
I know how to change the font color via preferences, but it changes the color of ALL text, as in below:
What I'm going for is something more like this:
Any tips?
A lot of unix terminals can recognise some (but usually not all) Ansi Escape codes
So you can use those (the ones that work for your terminal) to change the display as needed.
A very simple example (I use printf as it's portable across many different (and old!) shells) :
export _norm_="$(printf '\033[0m')" #reset "everything" to normal
export _bold_="$(printf '\033[1m')" #set bold
export _rred_="$(printf '\033[0;1;5;31m')" #"reverse red"
echo "This is an ${_rred_}ERROR${_norm_} and this is ${_bold_}A WARNING${_norm_}"
Please not that those may vary depending on the terminal type (TERM=...), and the program you connect to that machine with (most notably: reverse can become "blink" when using some windows terminal such as F-secure instead of Putty, for example..)
In other words: this is not completely portable, and depends on many things. But "bold" is quite always working. "reverse" is more prone to be terminal dependant.
tput
is also better to use as it's taking care to find out the proper sequence for your terminal, but it's not always available (not on old machines, for example)
As Olivier Dulac said, you need ANSI escape codes, please refer to Bash tips: Colors and formatting
for details.
sudo dpkg-reconfigure console-setup
tput
- in your$PS1
variable - or maybe in$PROMPT_COMMAND
. Play around with it. http://unix.stackexchange.com/questions/43075/how-to-change-the-contents-of-a-line-on-the-terminal-as-opposed-to-writing-a-new?rq=1 – mikeserv Jun 08 '14 at 07:41