Browse code

Merge branch 'completions' of https://github.com/gwjo/oh-my-zsh into gwjo-completions

Robby Russell authored on 19/11/2010 at 18:49:30
Showing 1 changed files
... ...
@@ -34,9 +34,31 @@ zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm
34 34
 zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
35 35
 cdpath=(.)
36 36
 
37
+# use /etc/hosts and known_hosts for hostname completion
38
+[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
39
+[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
40
+hosts=(
41
+  "$_ssh_hosts[@]"
42
+  "$_etc_hosts[@]"
43
+  `hostname`
44
+  localhost
45
+)
46
+zstyle ':completion:*:hosts' hosts $hosts
47
+
48
+# Use caching so that commands like apt and dpkg complete are useable
49
+zstyle ':completion::complete:*' use-cache 1
50
+zstyle ':completion::complete:*' cache-path ~/.oh-my-zsh/cache/
51
+
52
+# Don't complete uninteresting users
53
+zstyle ':completion:*:*:*:users' ignored-patterns \
54
+        adm amanda apache avahi beaglidx bin cacti canna clamav daemon \
55
+        dbus distcache dovecot fax ftp games gdm gkrellmd gopher \
56
+        hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \
57
+        mailman mailnull mldonkey mysql nagios \
58
+        named netdump news nfsnobody nobody nscd ntp nut nx openvpn \
59
+        operator pcap postfix postgres privoxy pulse pvm quagga radvd \
60
+        rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs
61
+
62
+# ... unless we really want to.
63
+zstyle '*' single-ignored show
37 64
 
38
-# Load known hosts file for auto-completion with ssh and scp commands
39
-if [ -f ~/.ssh/known_hosts ]; then
40
-  zstyle ':completion:*' hosts $( sed 's/[, ].*$//' $HOME/.ssh/known_hosts )
41
-  zstyle ':completion:*:*:(ssh|scp):*:*' hosts `sed 's/^\([^ ,]*\).*$/\1/' ~/.ssh/known_hosts`
42
-fi