summary refs log tree commit diff
path: root/Completion/Unix/Command/_su
blob: d8ed17183b3155750cbe15b3683196b4d7a13f74 (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

_contexts -o $shell $shell:t -default-