My Bash prompt seems to be wrapping lines really inefficiently. Here is an example to show what I mean:

enter image description here

I would like the commands that I am typing to continue onto the next line if the command length exceeds the window size.

My PS1 variable in the bashrc file is:

PS1='\e[0;36m\u \W: \e[m';

Perhaps tweaking this will help?

link|improve this question

72% accept rate
feedback

1 Answer

up vote 3 down vote accepted

Enclose the formatting sequences in escaped square brackets to let the terminal know that these characters aren't actually printed (for width calculations):

PS1='\[\e[0;36m\]\u \W: \[\e[m\]';

More details here in section Colors.

Edited to link to original submission on Meta, since whoever copied it to Blog.SU messed up pretty much everything.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.