my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
4.8 KiB

3 years ago
  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. # Use emacs key bindings
  17. bindkey -e
  18. # [PageUp] - Up a line of history
  19. if [[ -n "${terminfo[kpp]}" ]]; then
  20. bindkey -M emacs "${terminfo[kpp]}" up-line-or-history
  21. bindkey -M viins "${terminfo[kpp]}" up-line-or-history
  22. bindkey -M vicmd "${terminfo[kpp]}" up-line-or-history
  23. fi
  24. # [PageDown] - Down a line of history
  25. if [[ -n "${terminfo[knp]}" ]]; then
  26. bindkey -M emacs "${terminfo[knp]}" down-line-or-history
  27. bindkey -M viins "${terminfo[knp]}" down-line-or-history
  28. bindkey -M vicmd "${terminfo[knp]}" down-line-or-history
  29. fi
  30. # Start typing + [Up-Arrow] - fuzzy find history forward
  31. if [[ -n "${terminfo[kcuu1]}" ]]; then
  32. autoload -U up-line-or-beginning-search
  33. zle -N up-line-or-beginning-search
  34. bindkey -M emacs "${terminfo[kcuu1]}" up-line-or-beginning-search
  35. bindkey -M viins "${terminfo[kcuu1]}" up-line-or-beginning-search
  36. bindkey -M vicmd "${terminfo[kcuu1]}" up-line-or-beginning-search
  37. fi
  38. # Start typing + [Down-Arrow] - fuzzy find history backward
  39. if [[ -n "${terminfo[kcud1]}" ]]; then
  40. autoload -U down-line-or-beginning-search
  41. zle -N down-line-or-beginning-search
  42. bindkey -M emacs "${terminfo[kcud1]}" down-line-or-beginning-search
  43. bindkey -M viins "${terminfo[kcud1]}" down-line-or-beginning-search
  44. bindkey -M vicmd "${terminfo[kcud1]}" down-line-or-beginning-search
  45. fi
  46. # [Home] - Go to beginning of line
  47. if [[ -n "${terminfo[khome]}" ]]; then
  48. bindkey -M emacs "${terminfo[khome]}" beginning-of-line
  49. bindkey -M viins "${terminfo[khome]}" beginning-of-line
  50. bindkey -M vicmd "${terminfo[khome]}" beginning-of-line
  51. fi
  52. # [End] - Go to end of line
  53. if [[ -n "${terminfo[kend]}" ]]; then
  54. bindkey -M emacs "${terminfo[kend]}" end-of-line
  55. bindkey -M viins "${terminfo[kend]}" end-of-line
  56. bindkey -M vicmd "${terminfo[kend]}" end-of-line
  57. fi
  58. # [Shift-Tab] - move through the completion menu backwards
  59. if [[ -n "${terminfo[kcbt]}" ]]; then
  60. bindkey -M emacs "${terminfo[kcbt]}" reverse-menu-complete
  61. bindkey -M viins "${terminfo[kcbt]}" reverse-menu-complete
  62. bindkey -M vicmd "${terminfo[kcbt]}" reverse-menu-complete
  63. fi
  64. # [Backspace] - delete backward
  65. bindkey -M emacs '^?' backward-delete-char
  66. bindkey -M viins '^?' backward-delete-char
  67. bindkey -M vicmd '^?' backward-delete-char
  68. # [Delete] - delete forward
  69. if [[ -n "${terminfo[kdch1]}" ]]; then
  70. bindkey -M emacs "${terminfo[kdch1]}" delete-char
  71. bindkey -M viins "${terminfo[kdch1]}" delete-char
  72. bindkey -M vicmd "${terminfo[kdch1]}" delete-char
  73. else
  74. bindkey -M emacs "^[[3~" delete-char
  75. bindkey -M viins "^[[3~" delete-char
  76. bindkey -M vicmd "^[[3~" delete-char
  77. bindkey -M emacs "^[3;5~" delete-char
  78. bindkey -M viins "^[3;5~" delete-char
  79. bindkey -M vicmd "^[3;5~" delete-char
  80. fi
  81. # [Ctrl-Delete] - delete whole forward-word
  82. bindkey -M emacs '^[[3;5~' kill-word
  83. bindkey -M viins '^[[3;5~' kill-word
  84. bindkey -M vicmd '^[[3;5~' kill-word
  85. # [Ctrl-RightArrow] - move forward one word
  86. bindkey -M emacs '^[[1;5C' forward-word
  87. bindkey -M viins '^[[1;5C' forward-word
  88. bindkey -M vicmd '^[[1;5C' forward-word
  89. # [Ctrl-LeftArrow] - move backward one word
  90. bindkey -M emacs '^[[1;5D' backward-word
  91. bindkey -M viins '^[[1;5D' backward-word
  92. bindkey -M vicmd '^[[1;5D' backward-word
  93. bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark
  94. bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls
  95. 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.
  96. bindkey ' ' magic-space # [Space] - don't do history expansion
  97. # Edit the current command line in $EDITOR
  98. autoload -U edit-command-line
  99. zle -N edit-command-line
  100. bindkey '\C-x\C-e' edit-command-line
  101. # file rename magick
  102. bindkey "^[m" copy-prev-shell-word
  103. # consider emacs keybindings:
  104. #bindkey -e ## emacs key bindings
  105. #
  106. #bindkey '^[[A' up-line-or-search
  107. #bindkey '^[[B' down-line-or-search
  108. #bindkey '^[^[[C' emacs-forward-word
  109. #bindkey '^[^[[D' emacs-backward-word
  110. #
  111. #bindkey -s '^X^Z' '%-^M'
  112. #bindkey '^[e' expand-cmd-path
  113. #bindkey '^[^I' reverse-menu-complete
  114. #bindkey '^X^N' accept-and-infer-next-history
  115. #bindkey '^W' kill-region
  116. #bindkey '^I' complete-word
  117. ## Fix weird sequence that rxvt produces
  118. #bindkey -s '^[[Z' '\t'
  119. #