init.zsh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #
  2. # Completion enhancements
  3. #
  4. #
  5. # initialization
  6. #
  7. # if it's a dumb terminal, return.
  8. if [[ ${TERM} == 'dumb' ]]; then
  9. return 1
  10. fi
  11. # add the completions to the fpath
  12. fpath=(${0:h}/external/src ${fpath})
  13. # load and initialize the completion system
  14. autoload -Uz compinit && compinit -C -d "${ZDOTDIR:-${HOME}}/${zcompdump_file:-.zcompdump}"
  15. #
  16. # zsh options
  17. #
  18. # If a completion is performed with the cursor within a word, and a full completion is inserted,
  19. # the cursor is moved to the end of the word
  20. setopt ALWAYS_TO_END
  21. # Perform a path search even on command names with slashes in them.
  22. setopt PATH_DIRS
  23. # Make globbing (filename generation) not sensitive to case.
  24. unsetopt CASE_GLOB
  25. # Don't beep on an ambiguous completion.
  26. unsetopt LIST_BEEP
  27. #
  28. # completion module options
  29. #
  30. # group matches and describe.
  31. zstyle ':completion:*:*:*:*:*' menu select
  32. zstyle ':completion:*:matches' group yes
  33. zstyle ':completion:*:options' description yes
  34. zstyle ':completion:*:options' auto-description '%d'
  35. zstyle ':completion:*:corrections' format '%F{green}-- %d (errors: %e) --%f'
  36. zstyle ':completion:*:descriptions' format '%F{yellow}-- %d --%f'
  37. zstyle ':completion:*:messages' format '%F{purple}-- %d --%f'
  38. zstyle ':completion:*:warnings' format '%F{red}-- no matches found --%f'
  39. zstyle ':completion:*' format '%F{yellow}-- %d --%f'
  40. zstyle ':completion:*' group-name ''
  41. zstyle ':completion:*' verbose yes
  42. zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' '+r:|?=**'
  43. # directories
  44. if (( ! ${+LS_COLORS} )); then
  45. # Locally use same LS_COLORS definition from utility module, in case it was not set
  46. local LS_COLORS='di=1;34:ln=35:so=32:pi=33:ex=31:bd=1;36:cd=1;33:su=30;41:sg=30;46:tw=30;42:ow=30;43'
  47. fi
  48. zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
  49. zstyle ':completion:*:*:cd:*' tag-order local-directories directory-stack path-directories
  50. zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
  51. zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'expand'
  52. zstyle ':completion:*' squeeze-slashes true
  53. # enable caching
  54. zstyle ':completion::complete:*' use-cache on
  55. zstyle ':completion::complete:*' cache-path "${ZDOTDIR:-${HOME}}/.zcompcache"
  56. # ignore useless commands and functions
  57. zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec)|prompt_*)'
  58. # completion sorting
  59. zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
  60. # Man
  61. zstyle ':completion:*:manuals' separate-sections true
  62. zstyle ':completion:*:manuals.(^1*)' insert-sections true
  63. # history
  64. zstyle ':completion:*:history-words' stop yes
  65. zstyle ':completion:*:history-words' remove-all-dups yes
  66. zstyle ':completion:*:history-words' list false
  67. zstyle ':completion:*:history-words' menu yes
  68. # ignore multiple entries.
  69. zstyle ':completion:*:(rm|kill|diff):*' ignore-line other
  70. zstyle ':completion:*:rm:*' file-patterns '*:all-files'
  71. # If the _my_hosts function is defined, it will be called to add the ssh hosts
  72. # completion, otherwise _ssh_hosts will fall through and read the ~/.ssh/config
  73. zstyle -e ':completion:*:*:ssh:*:my-accounts' users-hosts \
  74. '[[ -f ${HOME}/.ssh/config && ${key} == hosts ]] && key=my_hosts reply=()'