Index

Subject : Re: LUG: [SOLVED] Help me spot the problem with PS1 definition

From : "Daniel Underwood" <daniel.underwood@ncsu.[redacted]>

Date : Tue, 20 Apr 2010 20:48:09 -0400

Parent


For those who may be interested, I found the flaw after reading
O'Reilly's "bash Cookbook"

This:

PS1='[\u@\[\e[0;31m\h\e[0m]\]:\W\$ '

Should be:

PS1='[\u@\[\e[0;31m\]\h\[\e[0m]\]:\W\$ '


EXPLANATION: "\e[0;31m" has to be enclosed within escaped brackets like
"\[\e[0;31m\]" because it's a non-printing character. Similarly,
"\e[0m]" must be enclosed within escaped brackets like "\[\e[0m]\]".
--
Daniel Underwood
North Carolina State University
Graduate Student - Operations Research
email: daniel.underwood@ncsu.[redacted]
phone: XXX.302.3291
web: http://www4.ncsu.edu/~djunderw/



Replies :