Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 22nd, 2003, 08:58 AM
wfsaxton wfsaxton is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 11 wfsaxton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 38 m 11 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old April 22nd, 2003, 01:32 PM
GNUbie's Avatar
GNUbie GNUbie is offline
Throws Rocks
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Location: Cincinnati, Ohio
Posts: 392 GNUbie User rank is Corporal (100 - 500 Reputation Level)GNUbie User rank is Corporal (100 - 500 Reputation Level)GNUbie User rank is Corporal (100 - 500 Reputation Level)GNUbie User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 6 h 31 m 7 sec
Reputation Power: 8
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.

Reply With Quote
  #3  
Old April 23rd, 2003, 09:39 AM
riv's Avatar
riv riv is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 463 riv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 37 m 50 sec
Reputation Power: 8
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.

Reply With Quote
  #4  
Old April 23rd, 2003, 10:43 AM
jbecherv's Avatar
jbecherv jbecherv is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Ontario, Canada
Posts: 5 jbecherv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to jbecherv Send a message via AIM to jbecherv
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

Reply With Quote
  #5  
Old April 25th, 2003, 10:20 AM
wfsaxton wfsaxton is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 11 wfsaxton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 38 m 11 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > Bash Prompt Issue


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway