You are not logged in.

#1 2008-10-13 23:45:29

pyther
Member
Registered: 2008-01-21
Posts: 1,395
Website

[solved][bash] PS1 wrapping problem...

Hello I have my ps1 set to

# Prompt
BGREEN='\[\033[1;32m\]'
GREEN='\[\033[0;32m\]'
BRED='\[\033[1;31m\]'
RED='\[\033[0;31m\]'
BBLUE='\[\033[1;34m\]'
BLUE='\[\033[0;34m\]'
NORMAL='\[\033[00m\]'

if [ "$TERM" = "linux" ]; then
    PS1="${NORMAL}[\u${BLUE}@\h ${BGREEN}\W${NORMAL}]\$ "
else
    PS1="\e]2;\u@\H:\w\a${NORMAL}[\u${BLUE}@\h ${BGREEN}\W${NORMAL}]$ "
fi

However when my prompt displays [pyther@tux world.pyther.net]$ (color) I can only type 3 characters and then it wraps. Please see the screenshot...

ps1_prompt_issue.png

Using a regular prompt (source /etc/profile) works like a charm. Any help would be great!

Last edited by pyther (2008-10-15 03:06:48)


Website - Blog - arch-home
Arch User since March 2005

Offline

#2 2008-10-13 23:49:42

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Re: [solved][bash] PS1 wrapping problem...

Try escaping the last $ in your else..fi block.

Last edited by byte (2008-10-13 23:50:07)


1000

Offline

#3 2008-10-14 00:12:14

pyther
Member
Registered: 2008-01-21
Posts: 1,395
Website

Re: [solved][bash] PS1 wrapping problem...

PS1="\e]2;\u@\H:\w\a${NORMAL}[\u${BLUE}@\h ${BGREEN}\W${NORMAL}]\$ "

As so? It gives me 5 characters, a slight improvment!


Website - Blog - arch-home
Arch User since March 2005

Offline

#4 2008-10-14 16:00:53

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: [solved][bash] PS1 wrapping problem...

Didn't I just answer this question in another thread? You need to escape the colors codes with \[ \] so that bash knows that they are non-printing characters, otherwise they will be counted in the prompt length.

Offline

#5 2008-10-14 21:31:42

pyther
Member
Registered: 2008-01-21
Posts: 1,395
Website

Re: [solved][bash] PS1 wrapping problem...

I am not sure what you mean, don't I have that?

NORMAL='\[\033[00m\]'


Website - Blog - arch-home
Arch User since March 2005

Offline

#6 2008-10-15 01:52:55

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: [solved][bash] PS1 wrapping problem...

Try changing the single quotes to double quotes in your color variable assignments.

Offline

#7 2008-10-15 03:01:39

pyther
Member
Registered: 2008-01-21
Posts: 1,395
Website

Re: [solved][bash] PS1 wrapping problem...

# Prompt
PS1="[\u\[\033[0;34m\]@\h \[\033[1;32m\]\W\[\033[00m\]]\$ "

# X Terminal titles
case "$TERM" in
xterm*|rxvt*)
        PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
        ;;
*)
        ;;
esac

The ps1 prompt I just put the color codes in. o_0

I found the second part in this thread and it worked wonders! http://bbs.archlinux.org/viewtopic.php?id=48358

Thanks for your help!

Last edited by pyther (2008-10-15 03:05:12)


Website - Blog - arch-home
Arch User since March 2005

Offline

#8 2008-10-15 19:40:14

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,000
Website

Re: [solved][bash] PS1 wrapping problem...

Daenyth wrote:

Didn't I just answer this question in another thread? You need to escape the colors codes with \[ \] so that bash knows that they are non-printing characters, otherwise they will be counted in the prompt length.

You're probably confusing this thread with mine a few days ago about using colors in PS1 in bash. ( http://bbs.archlinux.org/viewtopic.php? … 03#p432903 )

This issue is very similar indeed smile

Last edited by Dieter@be (2008-10-15 19:41:56)


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

Board footer

Powered by FluxBB