init.zsh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. # set any compdefs
  16. source ${0:h}/compdefs.zsh
  17. #
  18. # zsh options
  19. #
  20. # If a completion is performed with the cursor within a word, and a full completion is inserted,
  21. # the cursor is moved to the end of the word
  22. setopt ALWAYS_TO_END
  23. # Perform a path search even on command names with slashes in them.
  24. setopt PATH_DIRS
  25. # Make globbing (filename generation) not sensitive to case.
  26. unsetopt CASE_GLOB
  27. # Don't beep on an ambiguous completion.
  28. unsetopt LIST_BEEP
  29. #
  30. # completion module options
  31. #
  32. # group matches and describe.
  33. zstyle ':completion:*:*:*:*:*' menu select
  34. zstyle ':completion:*:matches' group yes
  35. zstyle ':completion:*:options' description yes
  36. zstyle ':completion:*:options' auto-description '%d'
  37. zstyle ':completion:*:corrections' format '%F{green}-- %d (errors: %e) --%f'
  38. zstyle ':completion:*:descriptions' format '%F{yellow}-- %d --%f'
  39. zstyle ':completion:*:messages' format '%F{purple}-- %d --%f'
  40. zstyle ':completion:*:warnings' format '%F{red}-- no matches found --%f'
  41. zstyle ':completion:*' format '%F{yellow}-- %d --%f'
  42. zstyle ':completion:*' group-name ''
  43. zstyle ':completion:*' verbose yes
  44. zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' '+r:|?=**'
  45. # directories
  46. if (( ${+LS_COLORS} )); then
  47. zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
  48. else
  49. zstyle ':completion:*:default' list-colors ${(s.:.)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}
  50. fi
  51. zstyle ':completion:*:*:cd:*' tag-order local-directories directory-stack path-directories
  52. zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
  53. zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'expand'
  54. zstyle ':completion:*' squeeze-slashes true
  55. # enable caching
  56. zstyle ':completion::complete:*' use-cache on
  57. zstyle ':completion::complete:*' cache-path "${ZDOTDIR:-${HOME}}/.zcompcache"
  58. # ignore useless commands and functions
  59. zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec)|prompt_*)'
  60. # completion sorting
  61. zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
  62. # Man
  63. zstyle ':completion:*:manuals' separate-sections true
  64. zstyle ':completion:*:manuals.(^1*)' insert-sections true
  65. # history
  66. zstyle ':completion:*:history-words' stop yes
  67. zstyle ':completion:*:history-words' remove-all-dups yes
  68. zstyle ':completion:*:history-words' list false
  69. zstyle ':completion:*:history-words' menu yes
  70. # ignore multiple entries.
  71. zstyle ':completion:*:(rm|kill|diff):*' ignore-line other
  72. zstyle ':completion:*:rm:*' file-patterns '*:all-files'