TMUX HOME END not working

I had a problem under OpenSuSE 13.1 with tmux 1.8-2.1.2 the home and end buttons did not work. It took me so long to find a solution but finally here it is, original link attached.

There is a nice tool called tput which can display the key sequence values that the system receives when a user hit a button, and another one bind which can map key sequences to another. This way it easy to spot that under tmux the system receives different sequence.

Test it like this:

$ cat -v # pressing home, then end
^[[1~^[[4~
$ tput khome | cat -v; echo
^[OH
$ tput kend | cat -v; echo
^[OF

And to make home and work again under tmux one needs to add these lines to ~/.bashrc:

if [[ -n "$TMUX" ]]; then
  bind '"\e[1~":"\eOH"'
  bind '"\e[4~":"\eOF"'
fi
Bonyiii Almost 10 years ago