about summary refs log tree commit diff
path: root/Completion/Unix/Command/_su
blob: 24fb5932ebada878269f7a1eef60a6aacbdbaf7f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#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

_dispatch $shell:t $shell $shell:t -default-