Reputation: 913
I'm following this blog to setup a zsh function to switch aws cli profiles : https://mads-hartmann.com/2017/04/27/multiple-aws-profiles.html
This is the zsh function in the blog:
function aws-switch() {
case ${1} in
"")
clear)
export AWS_PROFILE=""
;;
*)
export AWS_PROFILE="${1}"
;;
esac
}
#compdef aws-switch
#description Switch the AWS profile
_aws-switch() {
local -a aws_profiles
aws_profiles=$( \
grep '\[profile' ~/.aws/config \
| awk '{sub(/]/, "", $2); print $2}' \
| while read -r profile; do echo -n "$profile "; done \
)
_arguments \
':Aws profile:($(echo ${aws_profiles}) clear)'
}
_aws-switch "$@"
I added these lines to my ~/.zshrc, when I run source ~/.zshrc It gives /.zshrc:4: parse error near `)' I read the zsh function doc but still not very good at understanding the syntax and how could I fix this.
Upvotes: 0
Views: 922
Reputation: 22225
Have a look at the zsh man page (man zshmisc
):
case word in [ [(] pattern [ | pattern ] ... ) list (;;|;&|;|) ] ... esac
As you see, you have to separate multiple pattern by |
:
case $1 in
|clear)
....
Upvotes: 1