Skip to content

Instantly share code, notes, and snippets.

@briandeheus
Created October 2, 2020 10:20
Show Gist options
  • Save briandeheus/f52bc9aad9973260f1df2ad6d3d15a42 to your computer and use it in GitHub Desktop.
Save briandeheus/f52bc9aad9973260f1df2ad6d3d15a42 to your computer and use it in GitHub Desktop.

Revisions

  1. briandeheus renamed this gist Oct 2, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. briandeheus created this gist Oct 2, 2020.
    28 changes: 28 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    _get_gcp_accounts() {

    res=$(gcloud auth list --format="value(account)")
    for i in $res; do
    COMPREPLY+=("$i")
    done

    }

    _get_gcp_projects() {

    res=$(gcloud projects list --format="value(projectId)")
    for i in $res; do
    COMPREPLY+=("$i")
    done

    }

    googlesu() {
    gcloud config set account "$1"
    }

    googlesp() {
    gcloud config set project "$1"
    }

    complete -o default -F _get_gcp_accounts googlesu
    complete -o default -F _get_gcp_projects googlesp