diff options
author | Johannes Löthberg <johannes@kyriasis.com> | 2014-04-20 17:17:45 +0200 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2014-04-20 17:17:45 +0200 |
commit | 5631c1115ceba2fece9be67ec65e13ede10bba65 (patch) | |
tree | 04eddffad1463cc6023a9ce57f2131f92f519407 /zsh | |
parent | 62e549be111a9ae93fb32bab6e879d850174aa2c (diff) | |
download | dotfiles-5631c1115ceba2fece9be67ec65e13ede10bba65.tar.xz |
zshrc: Use terminfo for bindings instead of manually with zkbd
Diffstat (limited to 'zsh')
-rw-r--r-- | zsh/.zshrc | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -102,7 +102,22 @@ man() { man "$@" } -source ~/.config/zsh/.zkbd/$TERM-${${DISPLAY:t}:-$VENDOR-$OSTYPE} +# create a zkbd compatible hash; +# # to add other keys to this hash, see: man 5 terminfo +typeset -A key + +key[Home]=${terminfo[khome]} +key[End]=${terminfo[kend]} +key[Insert]=${terminfo[kich1]} +key[Delete]=${terminfo[kdch1]} +key[Up]=${terminfo[kcuu1]} +key[Down]=${terminfo[kcud1]} +key[Left]=${terminfo[kcub1]} +key[Right]=${terminfo[kcuf1]} +key[PageUp]=${terminfo[kpp]} +key[PageDown]=${terminfo[knp]} + +# setup key accordingly [[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line [[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line [[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode @@ -114,6 +129,19 @@ source ~/.config/zsh/.zkbd/$TERM-${${DISPLAY:t}:-$VENDOR-$OSTYPE} [[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" beginning-of-buffer-or-history [[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" end-of-buffer-or-history +# Finally, make sure the terminal is in application mode, when zle is +# active. Only then are the values from $terminfo valid. +if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then + function zle-line-init () { + printf '%s' "${terminfo[smkx]}" + } + function zle-line-finish () { + printf '%s' "${terminfo[rmkx]}" + } + zle -N zle-line-init + zle -N zle-line-finish +fi + alias sprin='curl -F "sprunge=<-" http://sprunge.us' sprfile() { curl -F "sprunge=<$1" http://sprunge.us |