completion.zsh 2.6 KB

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