Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GCP project in prompt #292

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions bullet-train.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if [ ! -n "${BULLETTRAIN_PROMPT_ORDER+1}" ]; then
virtualenv
nvm
aws
gcp
go
rust
elixir
Expand Down Expand Up @@ -118,6 +119,17 @@ if [ ! -n "${BULLETTRAIN_AWS_PREFIX+1}" ]; then
BULLETTRAIN_AWS_PREFIX="☁️"
fi

# GCP
if [ ! -n "${BULLETTRAIN_GCP_BG+1}" ]; then
BULLETTRAIN_GCP_BG=blue
fi
if [ ! -n "${BULLETTRAIN_GCP_FG+1}" ]; then
BULLETTRAIN_GCP_FG=white
fi
if [ ! -n "${BULLETTRAIN_GCP_PREFIX+1}" ]; then
BULLETTRAIN_GCP_PREFIX="G"
fi

# RUBY
if [ ! -n "${BULLETTRAIN_RUBY_BG+1}" ]; then
BULLETTRAIN_RUBY_BG=red
Expand Down Expand Up @@ -596,6 +608,26 @@ prompt_aws() {
fi
}

#GCP Profile
prompt_gcp() {
local spaces=" "

local gcp_profile=""
if [[ -n "${CLOUDSDK_ACTIVE_CONFIG_NAME}" && -f "$HOME/.config/gcloud/configurations/config_$CLOUDSDK_ACTIVE_CONFIG_NAME" ]]; then
gcp_profile="$CLOUDSDK_ACTIVE_CONFIG_NAME"
elif [[ -f "$HOME/.config/gcloud/active_config" ]]; then
gcp_profile=$(cat $HOME/.config/gcloud/active_config)
fi

local gcp_project=""
if [[ -n "${gcp_profile}" ]]; then
gcp_project=$(awk '/project/{print $3}' $HOME/.config/gcloud/configurations/config_$gcp_profile)
fi

if [[ -n "${gcp_project}" ]]; then
prompt_segment $BULLETTRAIN_GCP_BG $BULLETTRAIN_GCP_FG $BULLETTRAIN_GCP_PREFIX$spaces$gcp_project
fi
}
# SCREEN Session
prompt_screen() {
local session_name="$STY"
Expand Down