dotfiles

My dotfiles, nothing really interesting to see ...
git clone https://git.onna.be/dotfiles.git
Log | Files | Refs | README

commit a2578a61e35036956370bd6ba4eaa2ea58d823e3
parent ac90b68fb6027ab77395342f0ef95609ea57b7aa
Author: Paco Esteban <paco@onna.be>
Date:   Wed, 27 Jun 2018 12:29:50 +0200

caching gcloud context, as it is slow giving answers

Diffstat:
zsh/.zsh/aliases.zsh | 17+++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/zsh/.zsh/aliases.zsh b/zsh/.zsh/aliases.zsh @@ -201,6 +201,20 @@ function pastesrv() { } # google cloud prompt helper +function gctx () { + local context c_raw + context=$1 + if [[ -n "$context" ]]; then + gcloud config configurations activate $context && \ + echo $context > $HOME/.config/gcloud/current_context + else + c_raw=$(gcloud config configurations list) + context=$(echo $c_raw | awk '$2=="True" {print $1}') + echo "Available context: " + echo $c_raw | awk '{print $1}' | sed '1d' + echo "\nActive: $context" + fi +} function gCon () { export GCLOUD_PROMPT="true" } @@ -209,6 +223,5 @@ function gCoff () { unset GCLOUD_PROMPT } function gcloud_active_config () { - GCLOUD_CONFIG=$(gcloud config configurations list | awk '$2=="True" {print $1}') - echo "(gC:${GCLOUD_CONFIG})" + echo "(gC:$(cat $HOME/.config/gcloud/current_context))" }