This is a discussion on Colored PS1 reduces input line? within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> Hello everybody, I have noticed a strange thing with colored prompts in bash: they reduce the length of input ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello everybody, I have noticed a strange thing with colored prompts in bash: they reduce the length of input lines. AFAIK, an input line normally consists of 80 characters. As soon as I make PS1 colored (e.g., like PS1='\033[1;33m\h:\W$\033[0m ') the line reduces to less than 70 characters. Does this happen to you? Can this be fixed? Configuration HOWTO keeps silence on the subject :-/ Regards, Mikhail |
| |||
| muxaul@lenta.ru (Mikhail Zotov) wrote: >Hello everybody, > >I have noticed a strange thing with colored prompts in bash: >they reduce the length of input lines. AFAIK, an input line >normally consists of 80 characters. As soon as I make PS1 >colored (e.g., like PS1='\033[1;33m\h:\W$\033[0m ') the line >reduces to less than 70 characters. Well... look at all the added characters you have! Even though they are not printable characters, '\033[1;33m' sends 7 characters, and '\033[0m' sends for, so you are down to 69 on a line. >Does this happen to you? Can this be fixed? Configuration >HOWTO keeps silence on the subject :-/ See the Bash-Prompt-HOWTO, which will show that what you want is PS1='\[\033[1;33m\]\h:\W$\[\033[0m\] ') Where the escaped square brackets cause the enclosed text not to be counted. -- FloydL. Davidson <http://web.newsguy.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) floyd@barrow.com |
| |||
| Floyd L. Davidson wrote: > muxaul@lenta.ru (Mikhail Zotov) wrote: >>normally consists of 80 characters. As soon as I make PS1 >>colored (e.g., like PS1='\033[1;33m\h:\W$\033[0m ') the line >>reduces to less than 70 characters. > > Well... look at all the added characters you have! Even though > they are not printable characters, '\033[1;33m' sends 7 characters, > and '\033[0m' sends for, so you are down to 69 on a line. so *that's* what's wrong! man, this annoyed the heck out of me for i don't know how long! -- Joost Kremers joostkremers@yahoo.com Selbst in die Unterwelt dringt durch Spalten Licht EN:SiS(9) |
| |||
| -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 _.-In alt.os.linux.slackware, Floyd L. Davidson wrote the following -._ > Well... look at all the added characters you have! Even though > they are not printable characters, '\033[1;33m' sends 7 characters, > and '\033[0m' sends for, so you are down to 69 on a line. <snip> > See the Bash-Prompt-HOWTO, which will show that what you want > is > > PS1='\[\033[1;33m\]\h:\W$\[\033[0m\] ') Exactly. Another option which works is to add a new line at the end of the prompt. Which is how I fixed the issue. PS1="\e[0;36m+\e[1;36m-(\e[0;36m\u@\e[0;36m\h\e[1;36m)-(\e[0;36m\#/\e[0;36m\l\e[1;36m)-(\e[0;36m\t:\e[0;36m\d\e[1;36m)-\n\e[0;36m+\e[1;36m-(\e[0;36m\$:\e[0;36m\w\e[1;36m)-\e[0;0m\n" - -- .-')) http://asciipr0n.com/fp ('-. | It's a damn poor mind that ' ..- .:" ) ( ":. -.. ' | can only think of one way to ((,,_;'.;' UIN=66618055 ';. ';_,,)) | spell a word. ((_.YIM=Faux_Pseudo :._)) | - Andrew Jackson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFBbxUYSJec2PH9pbURAgBYAJ0VWCimg7fPvyUiJEOyBz I3nSc9RACff2zw rI9XHIAp9BNf1O7dCpY9dO4= =o/V2 -----END PGP SIGNATURE----- |
| ||||
| floyd@barrow.com (Floyd L. Davidson) wrote in message news:<87y8i9tfzr.fld@barrow.com>... > muxaul@lenta.ru (Mikhail Zotov) wrote: > >Hello everybody, > > > >I have noticed a strange thing with colored prompts in bash: > >they reduce the length of input lines. AFAIK, an input line > >normally consists of 80 characters. As soon as I make PS1 > >colored (e.g., like PS1='\033[1;33m\h:\W$\033[0m ') the line > >reduces to less than 70 characters. > > Well... look at all the added characters you have! Even though > they are not printable characters, '\033[1;33m' sends 7 characters, > and '\033[0m' sends for, so you are down to 69 on a line. > > >Does this happen to you? Can this be fixed? Configuration > >HOWTO keeps silence on the subject :-/ > > See the Bash-Prompt-HOWTO, which will show that what you want > is > > PS1='\[\033[1;33m\]\h:\W$\[\033[0m\] ' > > Where the escaped square brackets cause the enclosed text not to > be counted. Superb! Thanks a lot!! Regards, Mikhail |