completion.zsh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. # Complete . and .. special directories
  24. zstyle ':completion:*' special-dirs true
  25. zstyle ':completion:*' list-colors ''
  26. zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
  27. if [[ "$OSTYPE" = solaris* ]]; then
  28. zstyle ':completion:*:*:*:*:processes' command "ps -u $USERNAME -o pid,user,comm"
  29. else
  30. zstyle ':completion:*:*:*:*:processes' command "ps -u $USERNAME -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:*' use-cache yes
  36. zstyle ':completion:*' 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:-false} != false ]]; then
  50. expand-or-complete-with-dots() {
  51. # use $COMPLETION_WAITING_DOTS either as toggle or as the sequence to show
  52. [[ $COMPLETION_WAITING_DOTS = true ]] && COMPLETION_WAITING_DOTS="%F{red}…%f"
  53. # turn off line wrapping and print prompt-expanded "dot" sequence
  54. printf '\e[?7l%s\e[?7h' "${(%)COMPLETION_WAITING_DOTS}"
  55. zle expand-or-complete
  56. zle redisplay
  57. }
  58. zle -N expand-or-complete-with-dots
  59. # Set the function as the default tab completion widget
  60. bindkey -M emacs "^I" expand-or-complete-with-dots
  61. bindkey -M viins "^I" expand-or-complete-with-dots
  62. bindkey -M vicmd "^I" expand-or-complete-with-dots
  63. fi
  64. # automatically load bash completion functions
  65. autoload -U +X bashcompinit && bashcompinit