LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   bash prompt wrapping problems (https://www.linuxquestions.org/questions/linux-software-2/bash-prompt-wrapping-problems-367906/)

c0uchm0nster 09-28-2005 02:54 PM

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:
Code:

GRAD1=`tty|cut -d/ -f3`
COLOR1="\[\033[0;36m\]"
COLOR2="\[\033[1;36m\]"
COLOR3="\[\033[1;30m\]"
COLOR4="\[\033[0m\]"

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

thanks

edit: here's a version of ps1 without any $color entries - might be easier to follow
Code:

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)-- "

bigrigdriver 09-28-2005 09:17 PM

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.

c0uchm0nster 09-28-2005 10:41 PM

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?

c0uchm0nster 09-29-2005 06:07 PM

bump


All times are GMT -5. The time now is 12:18 AM.