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?
Asked
Active
Viewed 7,317 times
5
-
1Whats 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
-
2There 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
-
1What 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 Answers
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
linuxandrxvt) 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:
- Shell Tricks: .inputrc binding fun, illustrating hardcoding
- cursor keys not working on console, mentions
xterm-noappterminal description. - My cursor keys do not work (ncurses FAQ)
- Special keys (xterm manual, contrasting bash and ksh)
Thomas Dickey
- 75,040
- 9
- 171
- 268