1
0

completion.zsh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # set up
  2. if [ ! -d "${HOME}/.zsh/completion" ]; then
  3. mkdir -p "${HOME}/.zsh/completion"
  4. echo 'Downloading completions'
  5. curl -L https://raw.githubusercontent.com/docker/compose/1.23.1/contrib/completion/zsh/_docker-compose > ${HOME}/.zsh/completion/_docker-compose
  6. curl -L https://raw.githubusercontent.com/docker/cli/18.09/contrib/completion/zsh/_docker > ${HOME}/.zsh/completion/_docker
  7. fi
  8. fpath=(${HOME}/.zsh/completion $fpath)
  9. # make autocompletion faster by caching
  10. autoload -Uz compinit
  11. compinit -d "$HOME/.zsh/cache/zcompdump"
  12. zstyle ':completion:*' use-cache on
  13. zstyle ':completion:*' cache-path $HOME/.zsh/cache
  14. # use menu
  15. zstyle ':completion:*' menu select
  16. # enable approximate autocompletion
  17. zstyle ':completion:*' completer _complete _match _approximate
  18. zstyle ':completion:*:match:*' original only
  19. # zstyle ':completion:*:approximate:*' max-errors 1 numeric
  20. # zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3)) numeric)'
  21. # Smart matching of dashed values, e.g. f-b matching foo-bar
  22. zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*'
  23. # Group results by category
  24. zstyle ':completion:*' group-name ''
  25. # Keep directories and files separated
  26. zstyle ':completion:*' list-dirs-first true
  27. # Don't try parent path completion if the directories exist
  28. zstyle ':completion:*' accept-exact-dirs true
  29. zstyle ':completion:*' squeeze-slashes true
  30. # Always use menu selection for `cd -`
  31. zstyle ':completion:*:*:cd:*:directory-stack' force-list always
  32. zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
  33. # ignore completion functions for commands you don't have
  34. zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec)|TRAP*)'
  35. # Prettier completion for processes
  36. zstyle ':completion:*:*:*:*:processes' force-list always
  37. zstyle ':completion:*:*:*:*:processes' menu yes select
  38. zstyle ':completion:*:*:*:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
  39. zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,args -w -w"
  40. zstyle ':filter-select:highlight' matched fg=red
  41. zstyle ':filter-select' max-lines 10
  42. zstyle ':filter-select' rotate-list yes
  43. zstyle ':filter-select' case-insensitive yes # enable case-insensitive search
  44. # Use ls-colors for path completions
  45. function _set-list-colors() {
  46. zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
  47. unfunction _set-list-colors
  48. }
  49. sched 0 _set-list-colors # deferred since LC_COLORS might not be available yet