Index

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

From : Kevin Hunter <hunteke@earlham.[redacted]>

Date : Sun, 18 Apr 2010 19:25:33 -0400

Parent


At 4:43pm -0400 Sun, 18 Apr 2010, Daniel Underwood wrote:
> [My prompt definition is borked, somehow:]
> PS1='[\u@\[\e[0;31m\h\e[0m]\]:\W\$ '

> Here's what the text *should* be:
>
> ThisIsTextThatITypeButDoNotRunSo
>
> Here's what the text *actually* shows-up as:
>
> ThisIsTextThatITypeButooNotRunS

Your example with your prompt works for me. What doesn't work is if I
create a line that has to wrap in the window. Then I try to backspace
and can only visibly delete up to the wrap. The cursor won't "wrap
back" to the end of the previous line. This leads me to believe that
you haven't closed a control character properly.

I have a far more complicated prompt that took me a while to figure out.
At this point the details aren't fresh, but I recall having an issue
with \e[0m vs \e[0m]. I ended up using \033, defining the color codes
as variables, and then using colors via the more friendly "$COLOR_NAME"
reference. Ex:

PS1="$YELLOW\u$NORMAL@$RED\h\$ "

In any event, I think you've a closing error with '\e[0m' . It may help
you to define some color variables. You're welcome to use the variable
set that I currently use:

http://cygnus.ce.ncsu.edu/~kevin/dot.files/

Cheers,

Kevin


Replies :