From 0ff0ece5e25f6ab34019ff23a864a6c112485448 Mon Sep 17 00:00:00 2001 From: kernc Date: Mon, 24 Feb 2014 23:43:25 +0100 Subject: [PATCH 1/3] completion:**:users ignored-patterns more robust Calculates ignored users at runtime by extracting them from passwd database and considering all users with UID < 100 (on Solaris systems) or UID < 500 (everywhere else). By my timings, this doesn't make it any noticably slower. --- modules/completion/init.zsh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/completion/init.zsh b/modules/completion/init.zsh index 3ffad633..2e6094cd 100644 --- a/modules/completion/init.zsh +++ b/modules/completion/init.zsh @@ -99,14 +99,13 @@ zstyle -e ':completion:*:hosts' hosts 'reply=( )' # Don't complete uninteresting users... -zstyle ':completion:*:*:*:users' ignored-patterns \ - adm amanda apache avahi beaglidx bin cacti canna clamav daemon \ - dbus distcache dovecot fax ftp games gdm gkrellmd gopher \ - hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \ - mailman mailnull mldonkey mysql nagios \ - named netdump news nfsnobody nobody nscd ntp nut nx openvpn \ - operator pcap postfix postgres privoxy pulse pvm quagga radvd \ - rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs '_*' +zstyle ':completion:*:*:*:users' ignored-patterns nobody nobody4 noaccess '_*' \ + $([[ $OSTYPE =~ solaris ]] && max_uid=100 || max_uid=500 + IFS=: + while read user pass uid remainder; do + [[ ! $user =~ (^#|root) ]] && ((uid < max_uid)) && echo $user + done Date: Sat, 1 Mar 2014 21:13:31 +0100 Subject: [PATCH 2/3] Replace RE with glob expressions --- modules/completion/init.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/completion/init.zsh b/modules/completion/init.zsh index 2e6094cd..59f2b34c 100644 --- a/modules/completion/init.zsh +++ b/modules/completion/init.zsh @@ -100,10 +100,10 @@ zstyle -e ':completion:*:hosts' hosts 'reply=( # Don't complete uninteresting users... zstyle ':completion:*:*:*:users' ignored-patterns nobody nobody4 noaccess '_*' \ - $([[ $OSTYPE =~ solaris ]] && max_uid=100 || max_uid=500 + $([[ $OSTYPE = *(linux|darwin|cygwin)* ]] && min_uid=500 || min_uid=100 IFS=: - while read user pass uid remainder; do - [[ ! $user =~ (^#|root) ]] && ((uid < max_uid)) && echo $user + while read -r user pass uid remainder; do + [[ "$user" != (\#*|root) ]] && ((uid < min_uid)) && echo $user done Date: Sun, 2 Mar 2014 00:11:26 +0100 Subject: [PATCH 3/3] except SunOS only --- modules/completion/init.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/completion/init.zsh b/modules/completion/init.zsh index 59f2b34c..f68d713e 100644 --- a/modules/completion/init.zsh +++ b/modules/completion/init.zsh @@ -100,10 +100,10 @@ zstyle -e ':completion:*:hosts' hosts 'reply=( # Don't complete uninteresting users... zstyle ':completion:*:*:*:users' ignored-patterns nobody nobody4 noaccess '_*' \ - $([[ $OSTYPE = *(linux|darwin|cygwin)* ]] && min_uid=500 || min_uid=100 + $([[ "$OSTYPE" = SunOS ]] && uid_min=100 || uid_min=500 IFS=: while read -r user pass uid remainder; do - [[ "$user" != (\#*|root) ]] && ((uid < min_uid)) && echo $user + [[ "$user" != (\#*|root) ]] && ((uid < uid_min)) && echo $user done