10

Can anyone tell me what the key sequence is for these? I know if I do cat and type key presses I can get the code for it but how do I reverse that process to figure out what to press for beginning-of-line, for example?

bindkey '^[^[[D' backward-word
bindkey '^[^[[C' forward-word

bindkey '^[[5~' up-line-or-history
bindkey '^[[A' up-line-or-search
bindkey '^[[B' down-line-or-search
bindkey '^[[6~' down-line-or-history

bindkey '^[[5D' beginning-of-line
bindkey '^[[5C' end-of-line

bindkey '^[[3~' delete-char
bindkey '^?' backward-delete-char 

bindkey '^[^N' newtab
bindkey '^[[Z' reverse-menu-complete
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
maletor
  • 7,072
  • 7
  • 42
  • 63

2 Answers2

1

Tip: I've now published a more sophisticated version of the code below as part of the zsh-edit plugin.


You can use this function to do a reverse bindkey lookup:

reverse-bindkey-lookup() {
  print ${(k)terminfo[(Re)$(print -b - $1)]}
}

For example, when I run:

% reverse-bindkey-lookup '^[[Z'

I get as output:

cbt kcbt

These values you can then look up by doing

% man terminfo

and pressing / to search.


For the example above, I find:

back_tab                    cbt      bt     back tab (P)

and

key_btab                    kcbt     kB     back-tab key

Another example: If I run

% reverse-bindkey-lookup '^[[3~'

I get

kdch1

which man terminfo says is

key_dc                      kdch1    kD     delete-character key

Hopefully, you can then figure out from there what the actual key on your keyboard would be.


Marlon Richert
  • 5,250
  • 1
  • 18
  • 27
-1

I have no idea how to do reverse look up in general, just to provide some information for my Terminal (which should mimic xterm). This is done by Ctrl V (quoted-insert); replacing ^[ with \e for clarity.

  • \e[5~ / \e[6~ are PgUp PgDn
  • \e[A to \e[D are arrow keys
  • ^? is ← Backspace
  • \e[3~ is Delete
Franklin Yu
  • 8,920
  • 6
  • 43
  • 57