Created
December 7, 2022 22:29
-
-
Save tayopal/57c09f7b33263354eb0a503395bb1dd8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env zsh | |
function saws() | |
{ | |
valid_profiles=($(~/.local/bin/parse_aws_config)) | |
if [ -z "$1" ]; then | |
# Maybe just echo what profile is _still_ active | |
echo "Current profile is: $AWS_PROFILE" | |
return 0 | |
fi | |
if [[ ! " ${valid_profiles[@]} " =~ " ${1} " ]]; then | |
echo "Invalid profile name provided" | |
return -1 | |
# commands here when array doesn't contains a value | |
fi | |
export AWS_PROFILE=$1 | |
echo "Profile changed to: $AWS_PROFILE" | |
} | |
_saws_completions() | |
{ | |
COMPREPLY+=($(~/.local/bin/parse_aws_config)) | |
} | |
complete -F _saws_completions saws |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment