completion.zsh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. autoload -U compinit
  9. compinit -i
  10. zmodload -i zsh/complist
  11. ## case-insensitive (all),partial-word and then substring completion
  12. if [ "x$CASE_SENSITIVE" = "xtrue" ]; then
  13. zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
  14. unset CASE_SENSITIVE
  15. else
  16. zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
  17. fi
  18. zstyle ':completion:*' list-colors ''
  19. # should this be in keybindings?
  20. bindkey -M menuselect '^o' accept-and-infer-next-history
  21. zstyle ':completion:*:*:*:*:*' menu select
  22. zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
  23. zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w"
  24. # disable named-directories autocompletion
  25. zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
  26. cdpath=(.)
  27. # use /etc/hosts and known_hosts for hostname completion
  28. [ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
  29. [ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
  30. hosts=(
  31. "$_ssh_hosts[@]"
  32. "$_etc_hosts[@]"
  33. `hostname`
  34. localhost
  35. )
  36. zstyle ':completion:*:hosts' hosts $hosts
  37. # Use caching so that commands like apt and dpkg complete are useable
  38. zstyle ':completion::complete:*' use-cache 1
  39. zstyle ':completion::complete:*' cache-path ~/.oh-my-zsh/cache/
  40. # Don't complete uninteresting users
  41. zstyle ':completion:*:*:*:users' ignored-patterns \
  42. adm amanda apache avahi beaglidx bin cacti canna clamav daemon \
  43. dbus distcache dovecot fax ftp games gdm gkrellmd gopher \
  44. hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \
  45. mailman mailnull mldonkey mysql nagios \
  46. named netdump news nfsnobody nobody nscd ntp nut nx openvpn \
  47. operator pcap postfix postgres privoxy pulse pvm quagga radvd \
  48. rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs
  49. # ... unless we really want to.
  50. zstyle '*' single-ignored show