!comp.zsh 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. fpath=(
  2. "${${(%):-%x}:A:h}/local-completions"
  3. ~/.nix-profile/share/zsh/site-functions
  4. "${fpath[@]}"
  5. )
  6. autoload -U compinit
  7. compinit
  8. # fixme - the load process here seems a bit bizarre
  9. zmodload -i zsh/complist
  10. WORDCHARS=''
  11. unsetopt menu_complete # do not autoselect the first completion entry
  12. unsetopt flowcontrol
  13. setopt auto_menu # show completion menu on successive tab press
  14. setopt complete_in_word
  15. setopt always_to_end
  16. # should this be in keybindings?
  17. zstyle ':completion:*:*:*:*:*' menu select
  18. # case insensitive (all), partial-word and substring completion
  19. if [[ "$CASE_SENSITIVE" = true ]]; then
  20. zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*'
  21. else
  22. if [[ "$HYPHEN_INSENSITIVE" = true ]]; then
  23. zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*'
  24. else
  25. zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
  26. fi
  27. fi
  28. unset CASE_SENSITIVE HYPHEN_INSENSITIVE
  29. # Complete . and .. special directories
  30. zstyle ':completion:*' special-dirs false
  31. zstyle ':completion:*' list-colors "${LS_COLORS}"
  32. zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
  33. if [[ "$OSTYPE" = solaris* ]]; then
  34. zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm"
  35. else
  36. zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
  37. fi
  38. # disable named-directories autocompletion
  39. zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
  40. # Use caching so that commands like apt and dpkg complete are useable
  41. zstyle ':completion::complete:*' use-cache 1
  42. zstyle ':completion::complete:*' cache-path $ZSH_CACHE_DIR
  43. # Don't complete uninteresting users
  44. zstyle ':completion:*:*:*:users' ignored-patterns \
  45. adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
  46. clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
  47. gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
  48. ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
  49. named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
  50. operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
  51. rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
  52. usbmux uucp vcsa wwwrun xfs '_*'
  53. # ... unless we really want to.
  54. zstyle '*' single-ignored show
  55. if [[ $COMPLETION_WAITING_DOTS = true ]]; then
  56. expand-or-complete-with-dots() {
  57. # toggle line-wrapping off and back on again
  58. [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam
  59. print -Pn "%{%F{red}......%f%}"
  60. [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam
  61. zle expand-or-complete
  62. zle redisplay
  63. }
  64. zle -N expand-or-complete-with-dots
  65. bindkey "^I" expand-or-complete-with-dots
  66. fi
  67. zstyle ':completion:*' rehash true