Difference between revisions of "Home and End keys not working"
|Line 24:||Line 24:|
Revision as of 07:09, 1 September 2006
Why don't my Home and End keys work in terminals?
A: This is a common problem that seems to have multiple causes. There may be issues with the readline library, but it seems that the default
/etc/inputrc fixes these, at least in emacs mode.
The problem still seems to exist with ncurses based applications including less, nano, and centericq (to name but a few). These do not appear to use the readline library, or do not use the inputrc mappings.
The solution seems to be to have the proper setting of the
TERM variable. This may take some experimenting by looking in the /usr/share/terminfo/* directories. Each entry is a potential setting of the
In xterm setting
TERM=xterm-color DOES NOT solve the Home/End issues. This is often the default
TERM setting people recommend.
TERM=xterm-xfree86 seems to solve the problem. If you use the linux console instead of a terminal emulator, setting
TERM=linux seems to solve the problem. You can do this each time you start a terminal, or export it in your
Other terminals, including konsole, and rxvt have several entries in the terminfo database that you may need to experiment with. If you find a suitable
TERM setting for your favourite terminal, please enter it into this wiki file.
If you use a resource-based terminal such as xterm, rxvt, and aterm, another (better) way of solving the problem is to add
xterm*termName: xterm-xfree86 to your
~/.Xdefaults, and to add
xrdb ~/.Xdefaults to your
If you use KDE's Konsole, you can open the
Settings -> Configure Konsole menu item, click the
Session tab, select
Shell from the
Session list, and change the value of the
$TERM textfield to
Xorg users can try to set the
$TERM value to
xterm-xf86-v40. This one fix the home/end keys and prevent display corruption on nano and maybe other apps.
However, some urxvt (rxvt-unicode) users might still have problems after that. Adding the following to
~/.Xdefaults solves the problem
URxvt*keysym.Home: \e[1~ URxvt*keysym.End: \e[4~
In order to get the
END keys work properly in
less when using
TERM environmental variable must be set to
rxvt. You can test this on the fly by typing.
$ export TERM=rxvt-color $ export COLORTERM=rxvt
The above is what worked in my particular situation. I originally had the
COLORTERM environmental variable set to
rxvt. I believe it is set that way by installation of rxvt through pacman by default. So it may not be necessary to set that. It may even be superfluous. I'm am not sure. So I would recommend that you expirement to see if it's truly necessary. For me, what got the keys working right was the changing of
You may want to first check to see what your current environmental variables are for this.
$ printenv | grep TERM
If that doesn't work then you may want to use
lesskey to create set the key bindings for you. This was another step that I had done prior to all of the above. It may not have been necessary and did not seem to get the keys working.