View Single Post
Old 19th June 2008
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,290
Default

Quote:
Originally Posted by marcolino View Post
Just as an example, here is(are) the relevant line(s) from my .kshrc
Code:
export PS1='\[^[[1;36m\]\u\[^[[1;37m\]@\[^[[1;32m\]\h\[^[[0;34m\]\
(\l)\[^[[0m\]:\[^[[0;31m\]\w\[^[[0m\]\$ '
As an addendum, I don't deal with ANSI colors on a frequent basis, so remembering all the appropriate sequences isn't something I attempt. Plus, changing or simply debugging the above string has its own set of problems -- especially months, if not years after I originally wrote the code.

My suggestion adding to marcolino's example is to break the string further down into more manageable chunks. What I do is the following:
Code:
green='^[[01;32m'
yellow='^[[01;33m'
blue='^[[01;34m'
no_color='^[[0m'
prefix="${green}\u${yellow}@${green}\h${yellow}:${blue}\w"
char="${yellow} $ ${no_color}"
export PS1="${prefix}${char}"
FWIW.
Reply With Quote