completion.zsh 2.3 KB

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