completion.zsh 2.7 KB

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