5

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?

6
  • 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 'SO- stop being evil' Oct 23 '10 at 22:16
  • 1
    What do the commands echo $TERM and toe print? – ephemient Oct 23 '10 at 22:20
2

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:

1

Try typing

set -o emacs
3
  • 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
  • Already set. Still getting A B C S instead of arrow movement. – Ken Ingram Jan 26 '20 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy