Created
October 16, 2019 19:40
-
-
Save marcosinger/84d2df6075b1839be4fc4fe0ac8e951c to your computer and use it in GitHub Desktop.
Fish helpers to handle with gcloud config
This file contains 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
# ~/.config/completions/gswitch.fish | |
# | |
# creates a variable with the name of gcloud named configurations. Ex.: | |
# | |
# ~ glist | |
# NAME IS_ACTIVE ACCOUNT PROJECT | |
# aluminium False [email protected] aluminium-123 | |
# nickel True [email protected] nickel-001 | |
# zinc False [email protected] zinc-project | |
# | |
# echo $project | |
# > aluminium nickel zinc | |
set -l projects (glist | tail -n +2 | awk '{print $1}') | |
# autocomplete function gswitch based on $projects variable | |
# https://fishshell.com/docs/current/index.html#completion | |
complete -c gswitch -x -a '$projects' |
This file contains 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
# ~/.config/functions/glist.fish | |
function glist -d 'List gcloud named configurations' | |
gcloud config configurations list | |
end |
This file contains 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
# ~/.config/functions/gswitch.fish | |
function gswitch -d 'Switch between gcloud configurations' | |
gcloud config configurations activate $argv | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Command reference
https://cloud.google.com/sdk/gcloud/reference/config/configurations