Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 09-28-2005, 02:54 PM   #1
Registered: Nov 2003
Distribution: debian
Posts: 62

Rep: Reputation: 15
bash prompt wrapping problems

ive got a semi-custom (took most of it from an online example) bash prompt - but im having a bit of trouble with it wrapping incorrectly.

it wraps to the next line at the correct character - then i can type 1 more character, and the cursor goes to the beginning of the wrapped line and starts overwriting things there....
then if i hit delete enough it tries to wrap back but ends up displaying an extra line .... basically just very odd stuff
so my guess is im missing some escaping character stuff here - but i cant see where so extra pairs of eyes would be appreciated

here's the code:
GRAD1=`tty|cut -d/ -f3`

PS1="$COLOR3\[\\033(0lw\]\[\\033(B\]$COLOR1\[\\033(0q\]\[\\033(B\]$COLOR2($COLOR1\u$COLOR3@$COLOR1\h$COLOR2)$COLOR1\[\\033(0q\]\[\\03(B\]$COLOR2($COLOR1\#$COLOR3/$COLOR1$GRAD1$COLOR2)$COLOR1\[\\033(0q\]\[\\033(B\]$COLOR2($COLOR1\$(date +%I:%M%P)$COLOR3:$COLOR1\$(date +%m/%d/%y)$COLOR2)$COLOR1-$COLOR3-$COLOR4\n$COLOR3\[\\033(0mv\]\[\\033(B\]$COLOR1-$COLOR2($COLOR1\$$COLOR3:$COLOR1\w$COLOR2)$COLOR1-$COLOR3-$COLOR4 "
i do realize that there's a useless $COLOR4 at the end of the first line (right before the \n) but i'd like to leave this untouched until i can track down the weird wrapping problem


edit: here's a version of ps1 without any $color entries - might be easier to follow
PS1="\[\\033(0lw\]\[\\033(B\]\[\\033(0q\]\[\\033(B\](\u@\h)\[\\033(0q\]\[\\03(B\](\#/$GRAD1)\[\\033(0q\]\[\\033(B\](\$(date +%I:%M%P):\$(date +%m/%d/%y))--\n\[\\033(0mv\]\[\\033(B\]-(\$:\w)-- "

Last edited by c0uchm0nster; 09-28-2005 at 03:00 PM.
Old 09-28-2005, 09:17 PM   #2
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
After checking my own prompt, and re-reading the Bash Prompt HOWTO, it seems that, in every instance of [\\033(0lw\], or any other color reference, you have doubled the backslash after [ and before the number (033 or whatever). Every example I can find has only a single backslash after [ and before the number.

In the colors assigned to variable names, you have them with the single backslash.

Last edited by bigrigdriver; 09-28-2005 at 09:18 PM.
Old 09-28-2005, 10:41 PM   #3
Registered: Nov 2003
Distribution: debian
Posts: 62

Original Poster
Rep: Reputation: 15
ah that's a good point - however unfortunately it doesnt fix my problem.. it's a very weird problem not like any other wrapping problems i've had/seen before... hard to explain

by the way those arent color references - they're special characters - which might be related to the problem (as my understanding is \[\] stuff doesnt get counted as a character at all - whereas where im using them they're each 1 printed character)

anyone else have any ideas?

Last edited by c0uchm0nster; 09-28-2005 at 10:42 PM.
Old 09-29-2005, 06:07 PM   #4
Registered: Nov 2003
Distribution: debian
Posts: 62

Original Poster
Rep: Reputation: 15


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash prompt subG Slackware 6 01-18-2006 04:43 PM
help with bash prompt everythingand2 Linux - Newbie 7 12-06-2003 04:28 PM
Bash Prompt mandraketux Mandriva 2 11-28-2003 10:05 PM
uptime in bash prompt dekket Linux - Software 3 10-07-2003 12:39 PM
bash line wrapping gone awol acid_kewpie Linux - Software 10 05-14-2003 05:04 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:48 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration