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

2 Answers

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

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 Terminal.app, deleting the .plist file, and re-opening Terminal.app.

share|improve this answer
2  
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
add comment

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.