How to fix unix so that I can use the arrow keys in a terminal

keyboardterminal

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?

Best Answer

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: