bash prompt colours problem

Hello people,

i can't find a solution to this problem :

in my .bashrc, I have :

PS1="\[\033[7m\]\h:\w>\[\033[0m\] "

witch works very fine, except if I have an output without any \n :

ip-151:/tmp> echo -n FOO
ip-151:/tmp> p>

ip-151:/tmp> echo FOO
FOO
ip-151:/tmp>

It's a bit annoying... Have you had this problem ?
foudfou [ Fr, 11 April 2008 03:56 ] [ ID #1940024 ]

Re: bash prompt colours problem

On 2008-04-11, foudfou <foudil.newbie [at] bigfoot.com> wrote:
>
>
> Hello people,
>
> i can't find a solution to this problem :
>
> in my .bashrc, I have :
>
> PS1="\[\033[7m\]\h:\w>\[\033[0m\] "
>
> witch works very fine, except if I have an output without any \n :
>
> ip-151:/tmp> echo -n FOO
> ip-151:/tmp> p>
>
> ip-151:/tmp> echo FOO
> FOO
> ip-151:/tmp>
>
> It's a bit annoying... Have you had this problem ?

You could begin your prompt with \n.
Bill Marcum [ Fr, 11 April 2008 10:58 ] [ ID #1940028 ]

Re: bash prompt colours problem

Dear foudfou,

On Apr 11, 3:56 am, foudfou <foudil.new... [at] bigfoot.com> wrote:
> i can't find a solution to this problem :
>
> in my .bashrc, I have :
>
> PS1="\[\033[7m\]\h:\w>\[\033[0m\] "
>
> witch works very fine, except if I have an output without any \n :
>
> ip-151:/tmp> echo -n FOO
> ip-151:/tmp> p>
>
> ip-151:/tmp> echo FOO
> FOO
> ip-151:/tmp>
>
> It's a bit annoying... Have you had this problem ?

Not really with my bash (GNU bash, version 3.2.33(1)-release (i386-
redhat-linux-gnu)) it works as expected:

$ export PS1="\[\033[7m\]\h:\w>\[\033[0m\] "
matteo:~> echo FOO
FOO
matteo:~> echo -n FOO
FOOmatteo:~>

why version/platform are you using?

Matteo
Matteo Corti [ Fr, 11 April 2008 12:22 ] [ ID #1940031 ]

Re: bash prompt colours problem

Thank you for your answers.

Bill, your solution works. But I'd rather have no "\n" in my prompt.

Matteo, my version is : GNU bash, version 3.1.17(1)-release (i486-pc-
linux-gnu)
which comes with the standard debian/lenny distribution.

By the way, i'm using bash in "GNOME gnome-terminal 2.22.0", but I get
the same weird behaviour with xterm (XTerm(232)), or in the console !

also, I tried the following : export PS1="\e[07m\h:\w>\e[00m "
which works :

ip-151:~> echo -n FOO
FOOip-151:~>

but always writes on the same line instead of going to the next -
wrapping problem [I hope that's understandable...]

I have a small .inputrc :

set convert-meta on
M-p: history-search-backward
M-n: history-search-forward

and I did't notice anything special in /etc/profile or /etc/
bash.bashrc

I'll try with a newer version of Bash...
foudfou [ Fr, 11 April 2008 15:28 ] [ ID #1940039 ]

Re: bash prompt colours problem

foudfou wrote:
> Thank you for your answers.
>
> Bill, your solution works. But I'd rather have no "\n" in my prompt.
>
> Matteo, my version is : GNU bash, version 3.1.17(1)-release (i486-pc-
> linux-gnu)
> which comes with the standard debian/lenny distribution.
>
> By the way, i'm using bash in "GNOME gnome-terminal 2.22.0", but I get
> the same weird behaviour with xterm (XTerm(232)), or in the console !
>
> also, I tried the following : export PS1="\e[07m\h:\w>\e[00m "
> which works :
>
> ip-151:~> echo -n FOO
> FOOip-151:~>
>
> but always writes on the same line instead of going to the next -
> wrapping problem [I hope that's understandable...]
What else do you expect, if you explictly for bid echo to produce a new line
and don't want to do it in the prompt itsaelf?

> I have a small .inputrc :
>
> set convert-meta on
> M-p: history-search-backward
> M-n: history-search-forward
>
> and I did't notice anything special in /etc/profile or /etc/
> bash.bashrc
>
> I'll try with a newer version of Bash...
Don't think this would help.

Bye, Jojo
Joachim Schmitz [ Fr, 11 April 2008 15:36 ] [ ID #1940040 ]

Re: bash prompt colours problem

Hello Jojo,

that behavior I expect is exactly the one which is described by Teo :

matteo:~> echo -n FOO
FOOmatteo:~>

Maybe I wasn't clear about the problem : I have a prompt with colours,
and sometimes programs print something to stdout or stderr, but
without "\n". In this case, what I expect is the output, followed by
my shiny colored prompt. But what I get is that the output is not
printed, it seems overridden by the prompt. That's probably my config,
but I'm trying to figure out what/where is the problem.
foudfou [ Fr, 11 April 2008 16:43 ] [ ID #1940048 ]

Re: bash prompt colours problem

upgrading to bash-3.2 solved the problem.
Thank you all.
foudfou [ Fr, 11 April 2008 19:24 ] [ ID #1940070 ]
Linux » comp.unix.shell » bash prompt colours problem

Vorheriges Thema: Help with Sed command
Nächstes Thema: Set file permission without using chmod or umask??