|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Bash Prompt Issue
I'm having trouble setting the PS1 variable in my bash shell. Currently I have, in my .bashrc file:
PS1="\e]0;\h:\w\a\e[1;31m\h:\w \$\e[0m " This seems to work. That is, until i type a really long line. Then, instead of the line going to the edge of the terminal and wrapping around to the next line, it begins wrapping around 2/3 down the terminal, and it wraps around the same line, overwriting everything. If I continue typing, it overwrites the whole first line but then it goes to the edge of the terminal and wraps around to the next line...just like I'd expect it to work initially. Any ideas? This is happening on Solaris 9/Gnome 2.0 but I figure its probably not OS specific and there are more users here ![]() If I'm not making sense, here's an example: This is the way it should behave (assume the pipe after the j is the edge of the terminal): hostname:~ $ abcdefghij | kl This is what it does instead: ghijklme:~ $ abcdef |
|
#2
|
||||
|
||||
|
That isn't normal behavior for bash? Mine always did that. To compensate, I just put in a \ then hit enter and continue with the comand. For example:
Code:
gnubie@host~$ ./configure --verbose \ --prefix=/usr --enable-safe-mode \ --some-option --some-other-option
__________________
Two things have come out of Berkeley, Unix and LSD. It is uncertain which caused the other. |
|
#3
|
||||
|
||||
|
It should go automatically to the next line. Maybe you have the wrong TERM specified. Which one are you using?
__________________
Words must be weighed, not counted. |
|
#4
|
||||
|
||||
|
Answer to your bash prompt prayers
When using escape sequences in your PS1 variable, bash doesn't know about non-printables chars, so you have to tell it which ones are non-printable using by surrounding those chars with \[ and \]
Your PS1 should look something like this: PS1="\[\e[1;31m\]\h:\w \$\[\e[0;39m\] " Cheers, Jason Bechervaise |
|
#5
|
|||
|
|||
|
Sorry...been out fer Jury Duty.
I actually figured it out on my own and, yes, its the \[ \] stuff that makes it work. The prompt doesn't know where it actually is when you have non-printable chars. PS1="\[\033]0;\u@\h:\w\007\]\[\033[1;31m\]\h:\w $\[\033[0m\]" Works perfectly. Thanks. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > Linux Help > Bash Prompt Issue |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|