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 commonly have long terminal commands and whenever I try to use the command history (by pressing the up-arrow) the text formatting becomes all garbled and the cursor appears in the wrong place. At this point editing the command becomes impossible and the actual position of the cursor is not properly represented on the screen.

If I resize the terminal window to allows the entire command to fit on one line then the formatting gets corrected but sometimes I don't have enough screen real estate to accomplish this. Any ideas?

share|improve this question

Have you customized your shell prompt (e.g. colorization or something like that)? The usual reason that this happens is that you have non-printing characters in your prompt (e.g. color change sequences) and they confuse the shell about how wide the prompt is, and therefore how to wrap the command line.

Assuming you're using bash as your shell, the correct solution is to wrap the nonprinting sequences in \[...\] to let the shell know they're nonprinting. For instance, if you wanted your prompt to be blue (\e[0;34m to turn it blue, \e[m to go back to normal), you'd use:

PS1='\[\e[0;34m\]your prompt text here\[\e[m\]'
share|improve this answer
Can't upvote this enough. Wouldn't have thought the prompt could be screwing it up so bad. – Jonathan Dumaine Oct 17 '11 at 20:44

Is this happening on your local machine - by this, I mean you have not SSH'ed into another computer? If this is local, try quitting, deleting the .plist file, and re-opening

share|improve this answer
Whether or not this might work, it's crucial to explain that deleting the .plist file will delete ALL preferences for an app and that may or may not be what the OP wants. Better to just move it or rename it temporarily. – fideli Oct 4 '10 at 19:50

You must log in to answer this question.

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