Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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

Before I was able to use the Up/Down arrow keys to cycle through previous commands, but now when I press a directional key it outputs "^[[A". I'm running a bash shell. How do I fix this?

share|improve this question
1  
Whats your terminal? – echox Oct 23 '10 at 0:48
    
How would I find that information? – please help Oct 23 '10 at 1:09
    
@please: I expect that you are using a terminal emulator which is what you might call a "shell window" on whatever system you are running. As this is almost certainly so, your probably have a Help -> About menu selection: what does that say? What operating system are you running your terminal on? (e.g. Windows, MacOS, Debian, etc.) – msw Oct 23 '10 at 3:29
2  
There are many possibilities: your terminal is misconfigured (unlikely), your shell has wrong ideas about your terminal (less unlikely), you're getting a shell other than bash, etc. To start diagnosing, describe your OS (distribution, version, …), how you start a shell window, and the output of echo $TERM; ps -p $$ -p $PPID in a shell window. – Gilles Oct 23 '10 at 22:16
1  
What do the commands echo $TERM and toe print? – ephemient Oct 23 '10 at 22:20

The likely problem is that bash (not a full-screen program) is using termcap (for full-screen programs) and not accommodating the use of application mode in the key bindings.

The problem can be solved by one of these approaches:

  • hardcoding bindings in .inputrc (the route taken by most bash users)
  • choosing a terminal description which (like linux and rxvt) does not use application mode, or
  • improving bash so that (like the Debian package for zsh), it knows how to accept keys automatically whether they use normal or application mode.

Further reading:

share|improve this answer

Try typing

set -o emacs
share|improve this answer
    
That would be my advice, too. Seems like vi mode is enabled in the shell. – mru Oct 24 '10 at 18:29
    
Doesn't work for me. – Agi Hammerthief Mar 9 '14 at 12:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.