completion.zsh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # Relevant manpages:
  2. # - zshoptions
  3. # - zshcompwid
  4. # - zshcompsys
  5. setopt auto_menu # show completion menu on succesive tab press.
  6. setopt complete_in_word # Perform completion from both ends of a word.
  7. setopt always_to_end # Move cursor to end of word after completion.
  8. # Add custom completions from dotfiles to fpath.
  9. fpath=(~/dotfiles/shell/zsh/completions $fpath)
  10. # Load completion functions.
  11. #
  12. # `compinit` - Completion initisation.
  13. # `compaudit` - Finds insecure completion folders (wrong owner, 777) in fpath.
  14. # Used by compinit internally but can be added here to be called manually.
  15. # `compinstall` - Completion configurator.
  16. autoload -Uz compinit #compaudit compinstall
  17. # Initialise completion (and ignore compaudit check).
  18. compinit -i
  19. # Load zsh module for completion listing extensions.
  20. # Enables extensions for match highlighting, list scrolling and different
  21. # completion menu styles.
  22. zmodload -i zsh/complist
  23. # Colour completion listings.
  24. zstyle ':completion:*' list-colors ''
  25. # Highlight the current completion selection.
  26. zstyle ':completion:*' menu select
  27. # Case-insensitive completion.
  28. zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
  29. # Use caching so that commands like apt and dpkg complete are useable.
  30. zstyle ':completion::complete:*' use-cache on
  31. # Completion Waiting Dots.
  32. expand-or-complete-with-dots() {
  33. # Toggle line-wrapping off and back on again.
  34. [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam
  35. print -Pn "%{$FG[1]......$cReset%}"
  36. [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam
  37. zle expand-or-complete
  38. zle redisplay
  39. }
  40. zle -N expand-or-complete-with-dots
  41. bindkey "^I" expand-or-complete-with-dots