completion.zsh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # load completions system
  2. zmodload -i zsh/complist
  3. # auto rehash commands
  4. # http://www.zsh.org/mla/users/2011/msg00531.html
  5. zstyle ':completion:*' rehash true
  6. # vim keys in tab completion
  7. bindkey -M menuselect 'h' vi-backward-char
  8. bindkey -M menuselect 'j' vi-down-line-or-history
  9. bindkey -M menuselect 'k' vi-up-line-or-history
  10. bindkey -M menuselect 'l' vi-forward-char
  11. bindkey -v '^?' backward-delete-char
  12. # for all completions: menuselection
  13. zstyle ':completion:*' menu select=1
  14. # for all completions: grouping the output
  15. zstyle ':completion:*' group-name ''
  16. # for all completions: color
  17. zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
  18. # for all completions: selected item
  19. zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} ma=0\;47
  20. # completion of .. directories
  21. #zstyle ':completion:*' special-dirs true
  22. # fault tolerance
  23. zstyle ':completion:*' completer _complete _correct _approximate
  24. # (1 error on 3 characters)
  25. zstyle -e ':completion:*:approximate:*' max-errors 'reply=( $(( ($#PREFIX+$#SUFFIX)/3 )) numeric )'
  26. # case insensitivity
  27. #zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
  28. zstyle ":completion:*" matcher-list 'm:{A-Zöäüa-zÖÄÜ}={a-zÖÄÜA-Zöäü}'
  29. # for all completions: grouping / headline / ...
  30. zstyle ':completion:*:messages' format $'\e[01;35m -- %d -- \e[00;00m'
  31. zstyle ':completion:*:warnings' format $'\e[01;31m -- No Matches Found -- \e[00;00m'
  32. zstyle ':completion:*:descriptions' format $'\e[01;33m -- %d -- \e[00;00m'
  33. zstyle ':completion:*:corrections' format $'\e[01;33m -- %d -- \e[00;00m'
  34. # statusline for many hits
  35. zstyle ':completion:*:default' select-prompt $'\e[01;35m -- Match %M %P -- \e[00;00m'
  36. # for all completions: show comments when present
  37. zstyle ':completion:*' verbose yes
  38. # in menu selection strg+space to go to subdirectories
  39. bindkey -M menuselect '^@' accept-and-infer-next-history
  40. # case-insensitive -> partial-word (cs) -> substring completion:
  41. zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
  42. # caching of completion stuff
  43. zstyle ':completion:*' use-cache on
  44. zstyle ':completion:*' cache-path "$ZSH_CACHE"
  45. # ~dirs: reorder output sorting: named dirs over userdirs
  46. zstyle ':completion::*:-tilde-:*:*' group-order named-directories users
  47. # ssh: reorder output sorting: user over hosts
  48. zstyle ':completion::*:ssh:*:*' tag-order "users hosts"
  49. # kill: advanced kill completion
  50. zstyle ':completion::*:kill:*:*' command 'ps xf -U $USER -o pid,%cpu,cmd'
  51. zstyle ':completion::*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;32'
  52. # rm: advanced completion (e.g. bak files first)
  53. zstyle ':completion::*:rm:*:*' file-patterns '*.o:object-files:object\ file *(~|.(old|bak|BAK)):backup-files:backup\ files *~*(~|.(o|old|bak|BAK)):all-files:all\ files'
  54. # vi: advanced completion (e.g. tex and rc files first)
  55. zstyle ':completion::*:vi:*:*' file-patterns 'Makefile|*(rc|log)|*.(php|tex|bib|sql|zsh|ini|sh|vim|rb|sh|js|tpl|csv|rdf|txt|phtml|tex|py|n3):vi-files:vim\ likes\ these\ files *~(Makefile|*(rc|log)|*.(log|rc|php|tex|bib|sql|zsh|ini|sh|vim|rb|sh|js|tpl|csv|rdf|txt|phtml|tex|py|n3)):all-files:other\ files'
  56. zstyle ':completion:*' list-dirs-first true
  57. zstyle :compinstall filename '~/.zshrc'
  58. autoload -Uz compinit && compinit
  59. # Terraform completion
  60. #if [ -f /usr/bin/terraform ]; then
  61. # autoload -U +X bashcompinit && bashcompinit
  62. # complete -o nospace -C /usr/bin/terraform terraform
  63. #fi