mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-11-26 10:23:06 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2cd6260c5 |
+14
-11
@@ -247,17 +247,20 @@ function aws_profiles() {
|
|||||||
aws --no-cli-pager configure list-profiles 2> /dev/null
|
aws --no-cli-pager configure list-profiles 2> /dev/null
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
local line words
|
local file line words
|
||||||
# Only read the section headers, so the credentials never enter the shell
|
for file in "$config" "$creds"; do
|
||||||
for line in "${(@f)$(command grep -h '^[[:space:]]*\[' -- "$config" "$creds" 2> /dev/null)}"; do
|
# Only read the section headers, so the credentials never enter the shell
|
||||||
line=${line#*\[} # drop up to the first [
|
for line in "${(@f)$(command grep '^[[:space:]]*\[' -- "$file" 2> /dev/null)}"; do
|
||||||
line=${line%\]*} # drop from the last ] (comments, CR)
|
line=${line#*\[} # drop up to the first [
|
||||||
words=(${=line})
|
line=${line%\]*} # drop from the last ] (comments, CR)
|
||||||
if (( $#words == 1 )); then
|
words=(${=line})
|
||||||
print -r -- $words[1] # [default], or [foo] in the credentials file
|
if (( $#words == 1 )); then
|
||||||
elif (( $#words == 2 )) && [[ $words[1] == profile ]]; then
|
# [default], or any [foo] in the credentials file
|
||||||
print -r -- $words[2]
|
[[ $file == $creds || $words[1] == default ]] && print -r -- $words[1]
|
||||||
fi
|
elif (( $#words == 2 )) && [[ $words[1] == profile ]]; then
|
||||||
|
print -r -- $words[2]
|
||||||
|
fi
|
||||||
|
done
|
||||||
done | command sort -u
|
done | command sort -u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user