Help on controlling BASH command line

Andy Jack andy+lists-NouRTJlp5sIsA/PxXw9srA at public.gmane.org
Sat Jun 4 16:27:14 UTC 2005


On Sat, Jun 04, 2005 at 11:42:48AM -0400, pking123-rieW9WUcm8FFJ04o6PK0Fg at public.gmane.org wrote:
> I like coloured command prompts. My current one is:
>              PS1='\e[1;31m\h\e[m::\e[1;33m\w\e[m \e[1;32m>\e[m'
> Now if I type in a command, say of more than 20 characters, the 
> display goes nuts. That is, the cursor jumps to the previous line on 
> some nonrandom column and continues for another 5 or 6 characters, 
> then jumps to the previous line to that.

You probably need to turn off bash counting the number of characters in
the prompt around the escape codes for colors, and then turn it on again
after, with \[ and \] respectively (see man bash).

Give this a shot:

PS1='\[\e[1;31m\]\h\[\e[m\]::\[\e[1;33m\]\w\[\e[m\] \[\e[1;32m\]>\[\e[m\]'

hth,
Andy
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list