rice

personal dot files and scripts for linux and macOS
Log | Files | Refs | README | LICENSE

gcloud.zsh (799B)


      1 # Important shit to remember
      2 #    gcloud auth login
      3 #    gcloud auth applicaiton-default login
      4 
      5 # Commonly used gcloud commands
      6 alias g="gcloud"
      7 
      8 
      9 gac() {
     10     # Switch between google cloud configurations.
     11     cfg=$(gcloud config configurations list | awk 'NR!=-1 { print $1 }' | fzf -e)
     12     [ -z "$cfg" ] || gcloud config configurations activate $cfg
     13 }
     14 
     15 gssh() {
     16     # List out compute instances and ssh into a selected virtual
     17     # machine.
     18     instance=$(gcloud compute instances list | awk '/^gke/ { print $1 }' | sort | fzf)
     19     [ -z "$instance" ] || gcloud compute ssh $instance
     20 }
     21 
     22 gsp() {
     23     # Switch which google cloud project is currently configured.
     24     project=$(gcloud projects list | awk 'NR!=1 { print $1 }' | sort | fzf)
     25     [ -z "$project" ] || gcloud config set project $project
     26 }