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?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
  • 1
    Whats your terminal? – echox Oct 23 '10 at 00:48
  • How would I find that information? –  Oct 23 '10 at 01: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 03: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
  • I have the same problem, running GNOME Terminal (using xterm) as a non-root user. – Agi Hammerthief Mar 09 '14 at 12:02

2 Answers2

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:

Thomas Dickey
  • 75,040
  • 9
  • 171
  • 268
1

Try typing

set -o emacs
S010
  • 11
  • 1