key-bindings.zsh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. bindkey '^[[5~' up-line-or-history # [PageUp] - Up a line of history
  21. bindkey '^[[6~' down-line-or-history # [PageDown] - Down a line of history
  22. bindkey '^[[A' up-line-or-search # start typing + [Up-Arrow] - fuzzy find history forward
  23. bindkey '^[[B' down-line-or-search # start typing + [Down-Arrow] - fuzzy find history backward
  24. bindkey '^[[H' beginning-of-line # [Home] - Go to beginning of line
  25. bindkey '^[[1~' beginning-of-line # [Home] - Go to beginning of line
  26. bindkey '^[OH' beginning-of-line # [Home] - Go to beginning of line
  27. bindkey '^[[F' end-of-line # [End] - Go to end of line
  28. bindkey '^[[4~' end-of-line # [End] - Go to end of line
  29. bindkey '^[OF' end-of-line # [End] - Go to end of line
  30. bindkey ' ' magic-space # [Space] - do history expansion
  31. bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
  32. bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
  33. bindkey '^[[Z' reverse-menu-complete # [TODO] - Perform menu completion, like menu-complete, except that if a menu completion is already in progress, move to the previous completion rather than the next.
  34. # Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~
  35. bindkey '^?' backward-delete-char # [Delete] - delete backward
  36. bindkey '^[[3~' delete-char # [fn-Delete] - delete forward
  37. bindkey '^[3;5~' delete-char # [TODO] - delete forward
  38. bindkey '\e[3~' delete-char # [TODO] - delete forward
  39. # consider emacs keybindings:
  40. #bindkey -e ## emacs key bindings
  41. #
  42. #bindkey '^[[A' up-line-or-search
  43. #bindkey '^[[B' down-line-or-search
  44. #bindkey '^[^[[C' emacs-forward-word
  45. #bindkey '^[^[[D' emacs-backward-word
  46. #
  47. #bindkey -s '^X^Z' '%-^M'
  48. #bindkey '^[e' expand-cmd-path
  49. #bindkey '^[^I' reverse-menu-complete
  50. #bindkey '^X^N' accept-and-infer-next-history
  51. #bindkey '^W' kill-region
  52. #bindkey '^I' complete-word
  53. ## Fix weird sequence that rxvt produces
  54. #bindkey -s '^[[Z' '\t'
  55. #