Skip to content

Instantly share code, notes, and snippets.

@pebo
Created October 28, 2019 09:15
Show Gist options
  • Save pebo/55b177a79d025b77e048a43b4d9214a6 to your computer and use it in GitHub Desktop.
Save pebo/55b177a79d025b77e048a43b4d9214a6 to your computer and use it in GitHub Desktop.
Set GCP active config
gcp () {
if [ -z "$1" ]; then
echo "CLOUDSDK_ACTIVE_CONFIG_NAME=$CLOUDSDK_ACTIVE_CONFIG_NAME"
gcloud config configurations list
return 0
fi
export CLOUDSDK_ACTIVE_CONFIG_NAME=$1
if [[ $CLOUDSDK_ACTIVE_CONFIG_NAME =~ stage ]]
then
COLOR_PROFILE='\[\033[38;5;70m\]${CLOUDSDK_ACTIVE_CONFIG_NAME}\[$(tput sgr0)\]'
elif [[ $CLOUDSDK_ACTIVE_CONFIG_NAME =~ prod ]]
then
COLOR_PROFILE='\[$(tput setaf 1)\]${CLOUDSDK_ACTIVE_CONFIG_NAME}\[$(tput sgr0)\]'
else
COLOR_PROFILE='\[$(tput setaf 4)\]${CLOUDSDK_ACTIVE_CONFIG_NAME}\[$(tput sgr0)\]'
fi
export PS1="[$COLOR_PROFILE]:\W \u$ "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment