diff --git a/modules/editor/init.zsh b/modules/editor/init.zsh index 8f66aa5..89e640f 100644 --- a/modules/editor/init.zsh +++ b/modules/editor/init.zsh @@ -29,6 +29,8 @@ zmodload zsh/terminfo typeset -gA key_info key_info=( 'Control' '\C-' + 'ControlLeft' '\e[1;5D \e[5D \e\e[D' # sequences from Debian's inputrc + 'ControlRight' '\e[1;5C \e[5C \e\e[C' 'Escape' '\e' 'Meta' '\M-' 'Backspace' "^?" @@ -57,6 +59,12 @@ key_info=( 'BackTab' "$terminfo[kcbt]" ) +# additionally from Debian's inputrc +if [[ "$TERM" = *rxvt* ]]; then + key_info[ControlLeft]+=' \eOd' + key_info[ControlRight]+=' \eOc' +fi + # Set empty $key_info values to an invalid UTF-8 sequence to induce silent # bindkey failure. for key in "${(k)key_info[@]}"; do @@ -206,10 +214,12 @@ bindkey -d # Emacs Key Bindings # -for key ("$key_info[Escape]"{B,b}) bindkey -M emacs "$key" emacs-backward-word -for key ("$key_info[Escape]"{F,f}) bindkey -M emacs "$key" emacs-forward-word -bindkey -M emacs "$key_info[Escape]$key_info[Left]" emacs-backward-word -bindkey -M emacs "$key_info[Escape]$key_info[Right]" emacs-forward-word +for key ("${(s: :)key_info[ControlLeft]}" \ + "$key_info[Escape]"{B,b} "$key_info[Escape]$key_info[Left]") + bindkey -M emacs "$key" emacs-backward-word +for key ("${(s: :)key_info[ControlRight]}" \ + "$key_info[Escape]"{F,f} "$key_info[Escape]$key_info[Right]") + bindkey -M emacs "$key" emacs-forward-word # Kill to the beginning of the line. for key in "$key_info[Escape]"{K,k}