Created
October 28, 2019 09:15
-
-
Save pebo/55b177a79d025b77e048a43b4d9214a6 to your computer and use it in GitHub Desktop.
Set GCP active 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
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