Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make bash reverse-search work in Terminal.app without it displaying garbled output?

Tags:

bash

macos

Using Terminal.app on OS X 10.5, often you see the commands get garbled when you do a reverse-search with Bash. Is there some kind of termcap or perhaps a bash shopt command that can fix this? It is very annoying.

Steps to reproduce: Open Terminal.app, reverse-search to a longish command. Hit <ctrl>-E once you've found the command. The cursor goes to the end of the line, but the display doesn't update.

I'm guessing this is some kind of problem with the readline library on OS X. It's more of a problem with updating the cursor position after a search than anything else. Basically, ctrl-a and ctrl-e tend to break the search output.

os x terminal failure image http://involution.com/images/osxterminal.png

In the above, the first part of the command should be displayed, and the cursor should be at the end of the line, but it isn't. You literally can't see what you're editing when this happens.

like image 493
hoyhoy Avatar asked Aug 30 '08 01:08

hoyhoy


3 Answers

I was able to set my TERM to xterm instead of xterm-color and it solves the problem. (export TERM=xterm).

like image 188
Jason Haslup Avatar answered Nov 01 '22 07:11

Jason Haslup


You may want to look at this post.

bash-prompt-in-os-x-terminal-broken

I had the same problem and it had to do with the PS1 variable. Let me know if this helps.

like image 4
Milhous Avatar answered Nov 01 '22 07:11

Milhous


If the prompt has colors, then this is an acknowledged bug.
See bug report msg#00019.

like image 3
Adagios Avatar answered Nov 01 '22 06:11

Adagios