Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fix key settings (Home/End/Insert/Delete) in .zshrc when running Zsh in Terminator Terminal Emulator

I'm running Ubuntu 11.04. I installed the Terminator Terminal Emulator 0.95, and Zsh, version 4.3.15.
I have (commonly known) problems with my keys inside the Zsh. At least these:

  • Home/End, nothing happens
  • Insert/Delete/PageUp/PageDown: a "~" is typed

I already tried some configurations for .zshrc which should solve the problem, but no approach really worked so far. Maybe this is related to the combination of Terminator and Zsh. I took the 2 configs on this page: https://bbs.archlinux.org/viewtopic.php?pid=428669.

Does oneone have a similar configuration (especially Terminator and Zsh) and figured out what needs to be inserted into the .zshrc to fix the key settings?

like image 925
Wolkenarchitekt Avatar asked Dec 26 '11 18:12

Wolkenarchitekt


2 Answers

To know the code of a key, execute cat, press enter, press the key, then Ctrl+C.

For me, Home sends ^[[H and End ^[[F, so i can put i my .zshrc in my home dir

bindkey  "^[[H"   beginning-of-line bindkey  "^[[F"   end-of-line bindkey  "^[[3~"  delete-char 

These codes could change with the terminal emulator you use.

autoload zkbd ; zkbd will create a file with an array of keycodes to use, like bindkey "${key[Home]}" beginning-of-line, and you can source a different file depending on the terminal.

like image 98
lolesque Avatar answered Sep 21 '22 16:09

lolesque


Thanks to @lolesque, but the solution doesn't work with me. After using zkbd to check my key binding, I came out the below solution. BTW, my $TERM is xterm.

bindkey  "^[[1~"   beginning-of-line bindkey  "^[[4~"   end-of-line 

Hope it helps.

like image 22
eric Avatar answered Sep 20 '22 16:09

eric