about summary refs log tree commit diff
path: root/Completion/Unix/Command/_su
blob: a1dd69db841d2e55165c51a1437846038fa6860b (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 comps $shell $shell:t -default-