about summary refs log tree commit diff
path: root/Completion/Unix
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 12:03:16 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 12:03:16 +0000
commit0bfbe0c704a671a00078d880dbca0665eeaca7fb (patch)
tree1b233a8b55eeaeaa39d82b19b88a3bce0aa3f0e8 /Completion/Unix
parent9313787937cef5cb344dde702a1edeb6843d5ea9 (diff)
downloadzsh-0bfbe0c704a671a00078d880dbca0665eeaca7fb.tar.gz
zsh-0bfbe0c704a671a00078d880dbca0665eeaca7fb.tar.xz
zsh-0bfbe0c704a671a00078d880dbca0665eeaca7fb.zip
moved from Completion/User/_su
Diffstat (limited to 'Completion/Unix')
-rw-r--r--Completion/Unix/Command/_su22
1 files changed, 22 insertions, 0 deletions
diff --git a/Completion/Unix/Command/_su b/Completion/Unix/Command/_su
new file mode 100644
index 000000000..daf301555
--- /dev/null
+++ b/Completion/Unix/Command/_su
@@ -0,0 +1,22 @@
+#compdef su
+
+local shell comp name usr base
+
+[[ $words[2] != - ]]
+(( base=$?+2 ))
+
+if [[ CURRENT -eq base ]]; then
+  _users && return
+  usr=root
+elif [[ CURRENT -ge base+1 ]]; then
+  usr=$words[base]
+else
+  return
+fi
+
+shell="${${(M@)${(@f)$(</etc/passwd)}:#$usr*}##*:}"
+compset -n $base
+for name in $shell $shell:t -default-; do
+  comp="$_comps[$name]"
+  [[ -n "$comp" ]] && "$comp" && return
+done