key-bindings.zsh 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html
  2. # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins
  3. # http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets
  4. # Make sure that the terminal is in application mode when zle is active, since
  5. # only then values from $terminfo are valid
  6. if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
  7. function zle-line-init() {
  8. echoti smkx
  9. }
  10. function zle-line-finish() {
  11. echoti rmkx
  12. }
  13. zle -N zle-line-init
  14. zle -N zle-line-finish
  15. fi
  16. bindkey -e # Use emacs key bindings
  17. bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark
  18. bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls
  19. bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line.
  20. if [[ "${terminfo[kpp]}" != "" ]]; then
  21. bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history
  22. fi
  23. if [[ "${terminfo[knp]}" != "" ]]; then
  24. bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history
  25. fi
  26. if [[ "${terminfo[kcuu1]}" != "" ]]; then
  27. bindkey "${terminfo[kcuu1]}" up-line-or-search # start typing + [Up-Arrow] - fuzzy find history forward
  28. fi
  29. if [[ "${terminfo[kcud1]}" != "" ]]; then
  30. bindkey "${terminfo[kcud1]}" down-line-or-search # start typing + [Down-Arrow] - fuzzy find history backward
  31. fi
  32. if [[ "${terminfo[khome]}" != "" ]]; then
  33. bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
  34. fi
  35. if [[ "${terminfo[kend]}" != "" ]]; then
  36. bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
  37. fi
  38. bindkey ' ' magic-space # [Space] - do history expansion
  39. bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
  40. bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
  41. if [[ "${terminfo[kdch1]}" != "" ]]; then
  42. bindkey "${terminfo[kdch1]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards
  43. fi
  44. bindkey '^?' backward-delete-char # [Backspace] - delete backward
  45. if [[ "${terminfo[kdch1]}" != "" ]]; then
  46. bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward
  47. fi
  48. # Edit the current command line in $EDITOR
  49. autoload -U edit-command-line
  50. zle -N edit-command-line
  51. bindkey '\C-x\C-e' edit-command-line
  52. # consider emacs keybindings:
  53. #bindkey -e ## emacs key bindings
  54. #
  55. #bindkey '^[[A' up-line-or-search
  56. #bindkey '^[[B' down-line-or-search
  57. #bindkey '^[^[[C' emacs-forward-word
  58. #bindkey '^[^[[D' emacs-backward-word
  59. #
  60. #bindkey -s '^X^Z' '%-^M'
  61. #bindkey '^[e' expand-cmd-path
  62. #bindkey '^[^I' reverse-menu-complete
  63. #bindkey '^X^N' accept-and-infer-next-history
  64. #bindkey '^W' kill-region
  65. #bindkey '^I' complete-word
  66. ## Fix weird sequence that rxvt produces
  67. #bindkey -s '^[[Z' '\t'
  68. #