Skip to content

Instantly share code, notes, and snippets.

@FabioAntunes
Last active February 25, 2019 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FabioAntunes/14033e27feee7d305c1c3f771f661f8c to your computer and use it in GitHub Desktop.
Save FabioAntunes/14033e27feee7d305c1c3f771f661f8c to your computer and use it in GitHub Desktop.
function __fish_okta_complete_profiles
cat ~/.aws/config | grep -e "\[[^(okta)]" | awk -F'[] []' '{print $3}'
end
function __fish_complete_okta_subcommand
set -l tokens (commandline -opc) (commandline -ct)
set -l index (contains -i -- -- (commandline -opc))
set -e tokens[1..$index]
complete -C"$tokens"
end
set -l okta_commands add exec help login version
complete -f -c aws-okta -n "not __fish_seen_subcommand_from $okta_commands" -a add -d 'add your okta credentials'
complete -f -c aws-okta -n "not __fish_seen_subcommand_from $okta_commands" -a exec -d 'exec will run the command specified with aws credentials set in the environment'
complete -f -c aws-okta -n "not __fish_seen_subcommand_from $okta_commands" -a help -d 'help about any command'
complete -f -c aws-okta -n "not __fish_seen_subcommand_from $okta_commands" -a login -d 'login will authenticate you through okta and allow you to access your AWS environment through a browser'
complete -f -c aws-okta -n "not __fish_seen_subcommand_from $okta_commands" -a version -d 'print version'
complete -f -c aws-okta -n "__fish_seen_subcommand_from exec; and not __fish_seen_subcommand_from (__fish_okta_complete_profiles)" -a "(__fish_okta_complete_profiles)"
complete -f -c aws-okta -n "__fish_seen_subcommand_from (__fish_okta_complete_profiles); and not __fish_seen_subcommand_from --" -a "--"
complete -c aws-okta -n "contains -- -- (commandline -opc)" -x -a "(__fish_complete_okta_subcommand)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment