Strange behavior with PS1 prompt

Donald Russell russell.don at gmail.com
Mon Oct 19 19:50:20 UTC 2009


On Sat, Oct 17, 2009 at 22:02, Cameron Simpson <cs at zip.com.au> wrote:

> On 17Oct2009 21:16, Todd Zullinger <tmz at pobox.com> wrote:
> | I don't think this is a bug.  Rather, I think the problem is caused by
> | not escaping the color codes you have embedded in your prompt.  Try
> | this instead:
> |
> | export PS1="\n\[\033[0;35m\][\u@\h] ${PWD}\n$\[\033[0m\]"
> |
> | The \[ and \] begin and end a series of non-printable characters.
> | This tells bash not to count those characters when determining the
> | length of the prompt.  So the color escape sequences are wrapped in \[
> | and \].
>
> This is all beautiful, but I think you need to use single quotes instead
> of doubles.
>
>
Yes, single quotes is probably better, otherwise you have to escape the $ in
${PWD} for this to have the desired effect.

However, the point of the posting was to point out the error I had in not
properly encapsulating the ansi code/colors etc with \[...\]

Once I did that, my command line was behaving properly. :-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fedoraproject.org/pipermail/users/attachments/20091019/45899ca4/attachment-0001.html 


More information about the users mailing list