Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. # Borrowed from Arch Linux wiki
  2. # create a zkbd compatible hash;
  3. # to add other keys to this hash, see: man 5 terminfo
  4. typeset -g -A key
  5.  
  6. key[Home]="${terminfo[khome]}"
  7. key[End]="${terminfo[kend]}"
  8. key[Insert]="${terminfo[kich1]}"
  9. key[Backspace]="${terminfo[kbs]}"
  10. key[Delete]="${terminfo[kdch1]}"
  11. key[Up]="${terminfo[kcuu1]}"
  12. key[Down]="${terminfo[kcud1]}"
  13. key[Left]="${terminfo[kcub1]}"
  14. key[Right]="${terminfo[kcuf1]}"
  15. key[PageUp]="${terminfo[kpp]}"
  16. key[PageDown]="${terminfo[knp]}"
  17. key[ShiftTab]="${terminfo[kcbt]}"
  18.  
  19. # setup key accordingly
  20. [[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line
  21. [[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line
  22. [[ -n "${key[Insert]}" ]] && bindkey -- "${key[Insert]}" overwrite-mode
  23. [[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char
  24. [[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char
  25. [[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-history
  26. [[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-history
  27. #[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" history-search-backward # i miss up-line
  28. #[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" history-search-forward
  29. [[ -n "${key[Left]}" ]] && bindkey -- "${key[Left]}" backward-char
  30. [[ -n "${key[Right]}" ]] && bindkey -- "${key[Right]}" forward-char
  31. [[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history
  32. [[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" end-of-buffer-or-history
  33. [[ -n "${key[ShiftTab]}" ]] && bindkey -- "${key[ShiftTab]}" reverse-menu-complete
  34.  
  35.  
  36. # Finally, make sure the terminal is in application mode, when zle is
  37. # active. Only then are the values from $terminfo valid.
  38. #if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then
  39. # autoload -Uz add-zle-hook-widget
  40. # function zle_application_mode_start {
  41. # echoti smkx
  42. # }
  43. # function zle_application_mode_stop {
  44. # echoti rmkx
  45. # }
  46. # add-zle-hook-widget -Uz zle-line-init zle_application_mode_start
  47. # add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop
  48. #fi
  49. ### Same but for older zsh versions
  50. function zle-line-init () {
  51. if (( ${+terminfo[smkx]} )); then
  52. echoti smkx
  53. fi
  54. }
  55. function zle-line-finish () {
  56. if (( ${+terminfo[rmkx]} )); then
  57. echoti rmkx
  58. fi
  59. }
  60.  
  61. zle -N zle-line-init
  62. zle -N zle-line-finish
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement