forked from synfinatic/aws-sso-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc.sh
39 lines (34 loc) · 1.15 KB
/
zshrc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# AWS SSO requires `bashcompinit` which needs to be enabled once and
# only once in your shell. Hence we do not include the two lines:
#
# autoload -Uz +X compinit && compinit
# autoload -Uz +X bashcompinit && bashcompinit
#
# If you do not already have these lines, you must COPY the lines
# above, place it OUTSIDE of the BEGIN/END_AWS_SSO_CLI markers
# and of course uncomment it
__aws_sso_profile_complete() {
local _args=${AWS_SSO_HELPER_ARGS:- -L error}
_multi_parts : "($({{ .Executable }} ${=_args} list --csv Profile))"
}
aws-sso-profile() {
local _args=${AWS_SSO_HELPER_ARGS:- -L error}
if [ -n "$AWS_PROFILE" ]; then
echo "Unable to assume a role while AWS_PROFILE is set"
return 1
fi
eval $({{ .Executable }} ${=_args} eval -p "$1")
if [ "$AWS_SSO_PROFILE" != "$1" ]; then
return 1
fi
}
aws-sso-clear() {
local _args=${AWS_SSO_HELPER_ARGS:- -L error}
if [ -z "$AWS_SSO_PROFILE" ]; then
echo "AWS_SSO_PROFILE is not set"
return 1
fi
eval $({{ .Executable }} ${=_args} eval -c)
}
compdef __aws_sso_profile_complete aws-sso-profile
complete -C {{ .Executable }} aws-sso