简体   繁体   中英

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

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.

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

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.

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

Not sure whether this is the problem here, but a very common cause of a messed up screen in bash (with any terminal emulator, not just Terminal.app) is the window being resized.

Bash will read the window size when it starts up, and then assume it hasn't changed. When the window is resized a signal will be sent to whatever app is currently reading from the console. If this isn't bash (because you're running a text editor at the time, perhaps), then bash won't know about it.

Solution in this case is to resize the window again so that bash gets the signal and notices the new size.

I can't reproduce this, hitting either Ctrl + E , Ctrl + A or the arrow keys updates the command line correctly. Are you running 10.5.4? Is it perhaps a bug in earlier versions?

我遇到过这个bug,虽然我不知道如何解决它,你可以通过按<down><up>来解决它。

在最坏的情况下,您可以启动X服务器(在实用程序下的某个地方)并启动一个真正的xterm。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM