Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using Cygwin bash prompt, and for long commands the text will wrap around on the same line as opposed to going to the next line despite setting my PS1 to simply ' $'.

Here's a screenshot,
screenshot

share|improve this question
6  
What's the TERM environment variable set to? For the Cygwin console, it should be cygwin. –  ak2 May 14 '11 at 5:55
1  
@ak2 this fixed the problem for me, thank you. Cygwin on Mintty. –  JoshuaD Nov 20 '13 at 17:55

5 Answers 5

I was already using MinTTY, and removing the newline in PS1 didn't help either. One piece of advice on this page did help. I executed this bash command:

kill -WINCH $$

In my case, running this once fixed the issue, even after logging out and back in. I'm not sure if this is always the case.

share|improve this answer
    
Judging by -WINCH, this signals the bash process that the terminal window was resized. So this should be done after each terminal window resize, I guess. –  ivan_pozdeev Sep 26 '13 at 23:18
2  
@ivan_pozdeev, I just found you only have to do this is you resize while vim is open: vim gets the signal and redraws at the new size, but it isn't passed to its parent process and thus bash still thinks the size of the screen is whatever it was when vim opened. –  akatakritos Jan 16 at 16:29

I had the same problem with MinTTY as well. The problem probably has something to do with the primary prompt (PS1).

The solution for me was removing the last 'new line' character from PS1 (right before the '$' sign):

user@host ~
$ echo $PS1
\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$

user@host ~
$ export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\$ '

user@host ~ $

see http://cygwin.com/ml/cygwin/2001-07/msg00140.html for reference.

To make this change persistent, add export PS1='[\e]0;\w\a]\n[\e[32m]\u@\h [\e[33m]\w[\e[0m]\$ ' to your ~/.bashrc file.

share|improve this answer
    
Didn't work for me... –  HDave Mar 26 '14 at 19:36
    
This did work for me, but in addition to removing the last newline I had to also restart the Cygwin terminal. –  christosc Jul 10 at 9:44

For me, the solution was to add the following lines to .bashrc:

PS1='\[\e[32m\]\u@\h:\W> \[\e[0m\]'
TERM=cygwin
export PS1
export TERM

Note that non-printable characters in the prompt must be enclosed in \[ ... \].

share|improve this answer
1  
As mentioned by @ak2 in a comment under original question, export TERM=cygwin is sufficient to fix the issue. –  dregad Sep 30 '14 at 12:07
1  
it wasn't sufficient in my case. if PS1 contains escape sequences that aren't enclosed in \[...\], the wrapping problem would persist. setting the TERM env variable may be sufficient in your case, but i doubt it. –  digory doo Oct 1 '14 at 7:22

Something is broken in your terminal settings (probably).
I guess you would have already tried exiting that session and restarting a new one.

While you don't get a solution for the Cygwin terminal, give MinTTY a try (its actually better).

share|improve this answer
1  
I see this problem in Cygwin across multiple machines, but MinTTY looks better and solves the wrapping problem. Two birds with one stone! –  wting May 14 '11 at 21:10

As commented by dregad and ak2, setting export TERM=cygwin in my ~/.bashrc file was enough to fix this problem for me.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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