]> git.rmz.io Git - dotfiles.git/blob - zsh/lib/completion.zsh
merge oh-my-zsh into subdir
[dotfiles.git] / zsh / lib / completion.zsh
1 # fixme - the load process here seems a bit bizarre
2
3 unsetopt menu_complete # do not autoselect the first completion entry
4 unsetopt flowcontrol
5 setopt auto_menu # show completion menu on succesive tab press
6 setopt complete_in_word
7 setopt always_to_end
8
9 WORDCHARS=''
10
11 zmodload -i zsh/complist
12
13 ## case-insensitive (all),partial-word and then substring completion
14 if [ "x$CASE_SENSITIVE" = "xtrue" ]; then
15 zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
16 unset CASE_SENSITIVE
17 else
18 zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
19 fi
20
21 zstyle ':completion:*' list-colors ''
22
23 # should this be in keybindings?
24 bindkey -M menuselect '^o' accept-and-infer-next-history
25
26 zstyle ':completion:*:*:*:*:*' menu select
27 zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
28 zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w"
29
30 # disable named-directories autocompletion
31 zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
32 cdpath=(.)
33
34 # use /etc/hosts and known_hosts for hostname completion
35 [ -r /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$(</etc/ssh/ssh_known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _global_ssh_hosts=()
36 [ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
37 [ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
38 hosts=(
39 "$_global_ssh_hosts[@]"
40 "$_ssh_hosts[@]"
41 "$_etc_hosts[@]"
42 "$HOST"
43 localhost
44 )
45 zstyle ':completion:*:hosts' hosts $hosts
46
47 # Use caching so that commands like apt and dpkg complete are useable
48 zstyle ':completion::complete:*' use-cache 1
49 zstyle ':completion::complete:*' cache-path $ZSH/cache/
50
51 # Don't complete uninteresting users
52 zstyle ':completion:*:*:*:users' ignored-patterns \
53 adm amanda apache avahi beaglidx bin cacti canna clamav daemon \
54 dbus distcache dovecot fax ftp games gdm gkrellmd gopher \
55 hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \
56 mailman mailnull mldonkey mysql nagios \
57 named netdump news nfsnobody nobody nscd ntp nut nx openvpn \
58 operator pcap postfix postgres privoxy pulse pvm quagga radvd \
59 rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs
60
61 # ... unless we really want to.
62 zstyle '*' single-ignored show
63
64 if [ "x$COMPLETION_WAITING_DOTS" = "xtrue" ]; then
65 expand-or-complete-with-dots() {
66 echo -n "\e[31m......\e[0m"
67 zle expand-or-complete
68 zle redisplay
69 }
70 zle -N expand-or-complete-with-dots
71 bindkey "^I" expand-or-complete-with-dots
72 fi