Skip to main content

GCP Context

What​

Display the currently active GCP project, region and account

Sample Configuration​

− ▢ × 󱇶 cymbal-bank-prod :: alice@contoso.com _ ohmyposh.dev − ▢ × 󱇶 cymbal-bank-prod :: alice@contoso.com _ ohmyposh.dev

Template (info)​

default template
{{ if .Error }}{{ .Error }}{{ else }}{{ .Project }}{{ end }}

Properties​

NameTypeDescription
.Projectstringthe currently active project
.Accountstringthe currently active account
.Regionstringdefault region for the active context
.ActiveConfigstringthe active configuration name
.Authorizedboolfalse only when fetch_auth_status found an expired token
.TokenExpiresAttime.Timeexpiry of the cached access token, zero when unknown
.Errorstringcontains any error messages generated when trying to load the GCP config

Options​

NameTypeDefaultDescription
fetch_auth_statusbooleanfalsepopulate .Authorized and .TokenExpiresAt (see below)
note

fetch_auth_status reads access_tokens.db for the active account's cached access token. gcloud org reauth policies (e.g. "require reauthentication every 16 hours") enforce themselves through an opaque token with no readable expiry, so this can't predict the exact reauth moment. Instead, it reports whether the cached access token itself is still valid, which is a solid proxy: it stops refreshing once reauth is required.