Re: Little pb with fancy prompt
From: Icarus Sparry (usenet_at_icarus.freeuk.com)
Date: 05/29/04
- Next message: Icarus Sparry: "Re: quick confirmation"
- Previous message: Ego Shooter: "Re: Loop over files containing spaces"
- In reply to: Frédéric Mayot: "Little pb with fancy prompt"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 29 May 2004 20:02:20 GMT
On Sat, 29 May 2004 18:27:10 +0200, Frédéric Mayot wrote:
> I modified my bash prompt:
>
> PS1='\e[31;40m\u@\h:\e[32;40m\w\e[31;40m\$\e[0m '
>
> but it happens something strange: after 50 characters typed, it returns
> to the beginning of the line erasing what has been already typed.
The reason for this is that bash is counting the characters being output,
and assuming that each of them takes a space on the screen. However this
looks as if you are using ANSI escape sequences (or something based on
them), so that the \e[31;40m will actually take no space at all. To tell
bash that these take no space, put them inside a \[ \] pair, e.g.
PS1='\[\e[31;40m\]\u@\h:\[\e[32;40m\]\w\[\e[31;40m\]\$\[\e[0m\] '
This is described in the info page and the man page.
- Next message: Icarus Sparry: "Re: quick confirmation"
- Previous message: Ego Shooter: "Re: Loop over files containing spaces"
- In reply to: Frédéric Mayot: "Little pb with fancy prompt"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|