Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using GNOME Terminal 2.7.3 and zsh 4.3.9 (x86_64-unknown-linux-gnu)

Home and End are not working. Nothing happens and nothing gets displayed when I press them. but they work when I press shift + Home (Scrolls to the beginning of shell output.) and also work in other GUI programs. I googled and tried the following. No change :(

  885  bindkey "\e[1~" beginning-of-line
  886  bindkey "\e[H" beginning-of-line
  887  bindkey "\e1~" beginning-of-line
  888  bindkey "\eH" beginning-of-line
  889  bindkey "\e[0H" beginning-of-line

PS: When I am in the last tab and press Ctrl + pagedown I get ;5~ printed on the screen. Does that give any clue?

share|improve this question
Do 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? – bahamat Sep 8 '11 at 14:46
No I don't have .inputrc. I don't permission to create new user. This was always like that. I'am living with ctrl +a and ctrl+e. – balki Sep 8 '11 at 14:56
I guess in that case I won't suggest ctrl+a & ctrl+e ;-) – bahamat Sep 8 '11 at 14:59

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
share|improve this answer

Escape sequences sent by function and cursor keys consist of an escape character followed by printable characters. Press Ctrl+ 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
share|improve this answer
nothing gets printed when I press Ctrl then Home. Nothing happens. Tried changing 0 to O as well. – balki Sep 9 '11 at 14:07

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
share|improve this answer

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:

  1. 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

  2. Extract the terminal info infocmp $TERM >terminfo.src

  3. Open that file for editing, such as vim terminfo.src, look for khome and kend it's assigned to something, let's say khome=\E[1~ and kend=\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 and kend=\E[F.

  4. 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!

  5. run tic terminfo.src which creates ~/.terminfo directory.

  6. 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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.