Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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,

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

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
@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 '15 at 16:29
this also worked for me – konqui Dec 16 '15 at 14:47
This worked for me as well, thanks @jtpereyda ! – Jason R. Mick Jul 5 at 14:04

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 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 '15 at 9:44

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

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

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

share|improve this answer
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
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
For me this fixes the problem that the second line overwrites the first line, however unless I use exactly 80 width terminal, the cursor position and text offset are still wonky (using cygwin64 , mintty 2.3.7) – M.M Jun 1 at 1:24

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .