key-bindings.zsh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history
  21. bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history
  22. bindkey "${terminfo[kcuu1]}" up-line-or-search # start typing + [Up-Arrow] - fuzzy find history forward
  23. bindkey "${terminfo[kcud1]}" down-line-or-search # start typing + [Down-Arrow] - fuzzy find history backward
  24. bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
  25. bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
  26. bindkey ' ' magic-space # [Space] - do history expansion
  27. bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
  28. bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
  29. bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards
  30. bindkey '^?' backward-delete-char # [Backspace] - delete backward
  31. bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward
  32. # Edit the current command line in $EDITOR
  33. autoload -U edit-command-line
  34. zle -N edit-command-line
  35. bindkey '\C-x\C-e' edit-command-line
  36. # consider emacs keybindings:
  37. #bindkey -e ## emacs key bindings
  38. #
  39. #bindkey '^[[A' up-line-or-search
  40. #bindkey '^[[B' down-line-or-search
  41. #bindkey '^[^[[C' emacs-forward-word
  42. #bindkey '^[^[[D' emacs-backward-word
  43. #
  44. #bindkey -s '^X^Z' '%-^M'
  45. #bindkey '^[e' expand-cmd-path
  46. #bindkey '^[^I' reverse-menu-complete
  47. #bindkey '^X^N' accept-and-infer-next-history
  48. #bindkey '^W' kill-region
  49. #bindkey '^I' complete-word
  50. ## Fix weird sequence that rxvt produces
  51. #bindkey -s '^[[Z' '\t'
  52. #