Home key not working in terminal
Solution 1
Escape sequences sent by function and cursor keys consist of an escape character followed by printable characters. Press Ctrl+V then Home. This will insert the escape sequence literally. Then add a bindkey
instruction to your ~/.zshrc
.
The instruction is likely to be (note O
, not 0
):
bindkey '\e[OH' beginning-of-line
bindkey '\e[OF' end-of-line
Solution 2
I found I had to hit CTRL-v
, let go, then the Home
or End
key to get the sequences ^[[H
and ^[[F
for Home
and End
respectively. Adding the following lines to the .zshrc
file solved the problem for me:
bindkey '^[[H' beginning-of-line
bindkey '^[[F' end-of-line
Solution 3
I'm on fedora now yet I suggest you to read Archlinux's wiki carefully, all of it: Home and End keys not working.
What I did to fix it:
Press Ctrl-V Home, the escaped sequence for Home key is printed. It is not
\e[4~
and\e[1~
as I expected to be by looking at/etc/inputrc
. It was[H
and[F
Extract the terminal info
infocmp $TERM >terminfo.src
Open that file for editing, such as
vim terminfo.src
, look forkhome
andkend
it's assigned to something, let's saykhome=\E[1~
andkend=\E[4~
which is not working in this case. remove it and replace it with the sequence you found in step #1, so for me, after editing it was:khome=\E[H
andkend=\E[F
.If you want to play it safe make sure
[F
and[H
(or whatever sequence you just used) is not assigned to something else or things will be messed up!run
tic terminfo.src
which creates~/.terminfo
directory.On top of
.zshrc
before any and all other commands, put:export TERMINFO=~/.terminfo
Open a new terminal window and you should be fine, home and end must be working now.
P.S: The bindkey method should theoretically work and is easier, but it didn't for me.
Solution 4
Add these lines to /etc/zshrc
and then do a source /etc/zshrc
(taken from here)
bindkey '\e[1~' beginning-of-line # Linux console
bindkey '\e[H' beginning-of-line # xterm
bindkey '\eOH' beginning-of-line # gnome-terminal
bindkey '\e[2~' overwrite-mode # Linux console, xterm, gnome-terminal
bindkey '\e[3~' delete-char # Linux console, xterm, gnome-terminal
bindkey '\e[4~' end-of-line # Linux console
bindkey '\e[F' end-of-line # xterm
bindkey '\eOF' end-of-line # gnome-terminal
Solution 5
This answer explained my problem really good and fixed it.
https://stackoverflow.com/a/686458/5472892
TL;DR: Change your PuTTY terminal type from default xterm
to linux
.
Maybe someone can use it too.
Related videos on Youtube
ASD
Updated on September 18, 2022Comments
-
ASD over 1 year
SELECT description FROM diagnosis_mapping LEFT JOIN diagnosis_codes ON diagnosis_codes.codeid = diagnosis_mapping.codeid SELECT description FROM diagnosis_mapping LEFT JOIN diagnosis_codes ON diagnosis_codes.codeid = diagnosis_mapping.secondarycodeid
How to merge these 2 queries and get info in a single resultset? In first i need to match with codeid and in second i need to match with secondarycodeid to the same mastertable to fetch the description of both.
-
bahamat over 12 yearsDo you have a
.inputrc
in your home directory? Does this happen with a freshly created user? Did this always happen, or did it start one day? -
Chris Perkins over 12 yearsNo I don't have
.inputrc
. I don't permission to create new user. This was always like that. I'am living withctrl +a
andctrl+e
. -
bahamat over 12 yearsI guess in that case I won't suggest
ctrl+a
&ctrl+e
;-)
-
-
Wim over 14 yearsAlso best give an alias to the result fields (
a.description desc_a, b.description desc_b
) as most frameworks returning an associative array (f.i. PHP'smysql_fetch_assoc
) ignore the table name component and would otherwise give you back only onedescription
field. -
Tatu Ulmanen over 14 years@Wim, you're absolutely right, my example wouldn't be very usable without them. I've edited my answer.
-
ASD over 14 yearsIts Working. Thanks. Even the idea of giving alias to the resultfields is cool. Its great. Thanks for all your help in getting me done.
-
Chris Perkins over 12 yearsnothing gets printed when I press Ctrl then Home. Nothing happens. Tried changing 0 to O as well.
-
Gilles 'SO- stop being evil' almost 7 years@balki It's Ctrl+V, not Ctrl. I just realized there was a formatting problem in my answer.
-
Chris Perkins almost 7 yearsThanks! :) I am now used to
ctrl + a
andctrl +e
and vi mode -
Kasia Gauza about 4 yearsAlso tested in CentOS + bash - works! Thank you :)
-
Tyler Kelly over 3 years+1: it was mentioned in the link, but i was unaware that if doing ctrl-v gave me
^[[H
that you should replace the^[
with\e
to get\e[H
-
David Balažic about 3 yearsSo now it wont work in terminals that properly emulate xterm? Or does he have a broken terminfo?
-
stwr667 about 2 yearsI had this problem but only in IRB ruby shells, not in ZSH shells. To fix, I added
"\e[H":beginning-of-line
and"\e[F":end-of-line
lines to~/.inputrc