add inputs module

This commit is contained in:
Matt Hamilton 2015-12-16 01:15:30 -05:00
parent 2a4e052939
commit 79995ae5ee
2 changed files with 70 additions and 0 deletions

6
modules/inputs/README.md Normal file
View File

@ -0,0 +1,6 @@
Inputs
======
Applys correct bindkeys for inputs.
Without this module, you may experience oddities in how Zsh interprets input. For example, using the UP key, then using the back arrow and pressing DELETE may capatalize characters rather than delete them.

64
modules/inputs/init.zsh Normal file
View File

@ -0,0 +1,64 @@
#
# Editor and input char assignment
#
# Return if requirements are not found.
if [[ "$TERM" == 'dumb' ]]; then
return 1
fi
# Use human-friendly identifiers.
zmodload zsh/terminfo
typeset -gA key_info
key_info=(
'Control' '\C-'
'ControlLeft' '\e[1;5D \e[5D \e\e[D \eOd'
'ControlRight' '\e[1;5C \e[5C \e\e[C \eOc'
'Escape' '\e'
'Meta' '\M-'
'Backspace' "^?"
'Delete' "^[[3~"
'F1' "$terminfo[kf1]"
'F2' "$terminfo[kf2]"
'F3' "$terminfo[kf3]"
'F4' "$terminfo[kf4]"
'F5' "$terminfo[kf5]"
'F6' "$terminfo[kf6]"
'F7' "$terminfo[kf7]"
'F8' "$terminfo[kf8]"
'F9' "$terminfo[kf9]"
'F10' "$terminfo[kf10]"
'F11' "$terminfo[kf11]"
'F12' "$terminfo[kf12]"
'Insert' "$terminfo[kich1]"
'Home' "$terminfo[khome]"
'PageUp' "$terminfo[kpp]"
'End' "$terminfo[kend]"
'PageDown' "$terminfo[knp]"
'Up' "$terminfo[kcuu1]"
'Left' "$terminfo[kcub1]"
'Down' "$terminfo[kcud1]"
'Right' "$terminfo[kcuf1]"
'BackTab' "$terminfo[kcbt]"
)
# Bind the keys
bindkey "$key_info[Home]" beginning-of-line
bindkey "$key_info[End]" end-of-line
bindkey "$key_info[Insert]" overwrite-mode
bindkey "$key_info[Delete]" delete-char
bindkey "$key_info[Backspace]" backward-delete-char
bindkey "$key_info[Left]" backward-char
bindkey "$key_info[Right]" forward-char
# Expandpace.
bindkey ' ' magic-space
# Clear
bindkey "$key_info[Control]L" clear-screen
# Bind Shift + Tab to go to the previous menu item.
bindkey "$key_info[BackTab]" reverse-menu-complete