summaryrefslogtreecommitdiff
path: root/Completion/Unix/Command
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2004-01-14 17:01:11 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2004-01-14 17:01:11 +0000
commit356f432985b76ce8a0fe71fef2ec433517605477 (patch)
tree83e790612a5ba2ea1d2ba262a5fdb9fa066c4751 /Completion/Unix/Command
parent87821ed853fba324a4249786af4984a984b96dac (diff)
downloadzsh-356f432985b76ce8a0fe71fef2ec433517605477.tar.gz
zsh-356f432985b76ce8a0fe71fef2ec433517605477.zip
19364: new completions for aptitude, getent and catcgsegv
Diffstat (limited to 'Completion/Unix/Command')
-rw-r--r--Completion/Unix/Command/.distfiles2
-rwxr-xr-xCompletion/Unix/Command/_getent50
2 files changed, 51 insertions, 1 deletions
diff --git a/Completion/Unix/Command/.distfiles b/Completion/Unix/Command/.distfiles
index 04e83bead..d3ba38e00 100644
--- a/Completion/Unix/Command/.distfiles
+++ b/Completion/Unix/Command/.distfiles
@@ -21,6 +21,6 @@ _netcat _larch _texinfo _figlet _elinks _tidy
_global _ant _lsof _mt _xmlsoft
_perforce _python _antiword _screen _renice _apm
_ecasound _gpg _subversion _aap _sablotron _nmap
-_chmod _du
+_chmod _du _getent
_nice _rar _vorbis
'
diff --git a/Completion/Unix/Command/_getent b/Completion/Unix/Command/_getent
new file mode 100755
index 000000000..57d2ec256
--- /dev/null
+++ b/Completion/Unix/Command/_getent
@@ -0,0 +1,50 @@
+#compdef getent
+
+local curcontext="$curcontext" state line expl ret=1
+local services databases keys
+local -a args
+typeset -A opt_args
+
+if _pick_variant -r is_gnu gnu=GNU unix --version; then
+ args+=(
+ '(- 1 *)'{-\?,--help}'[display help information]'
+ '(- 1 *)--usage[display a short usage message]'
+ '(- 1 *)'{-V,--version}'[display version information]'
+ {-s,--service=}'[specify service configuration to use]:service:->services'
+ )
+fi
+
+_arguments -C "$args[@]" \
+ '1:database:->databases' \
+ '*:key:->keys' && ret=0
+
+case $state in
+ services)
+ services=( /lib/libnss*(-.:fr:t:s/libnss_//) )
+ _wanted services expl service compadd ${services%-*} && ret=0
+ ;;
+ databases)
+ if [[ $is_gnu = gnu ]]; then
+ databases=( ${=${${(f)"$(_call_program databases $words[1] --help \
+ 2>/dev/null)"}[(r)Supported*,-1]}[2,-1]} )
+ else
+ databases=( passwd group hosts ipnodes services protocols ethers networks netmasks )
+ fi
+ _wanted databases expl database compadd -a databases && ret=0
+ ;;
+ keys)
+ keys=( ${(f)"$(_call_program keys $words[1] ${(kv)opt_args[(i)-s|--service]} $line[1] 2>/dev/null)"} )
+ case $line[1] in
+ *hosts) _wanted keys expl key compadd ${=keys#* } && ret=0 ;;
+ networks|rpc|protocols|services)
+ _wanted keys expl key compadd ${=keys%% *} && ret=0
+ ;;
+ aliases|passwd|shadow|group)
+ _wanted keys expl key compadd ${keys%%:*} && ret=0
+ ;;
+ *) _message -e keys key;;
+ esac
+ ;;
+esac
+
+return ret