diff --git a/docs/themes-list/powerline-base.rst b/docs/themes-list/powerline-base.rst index d0f6ab3051..85ba2388d1 100644 --- a/docs/themes-list/powerline-base.rst +++ b/docs/themes-list/powerline-base.rst @@ -70,6 +70,7 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o * ``battery`` - Battery information (you'll need to enable the ``battery`` plugin) * ``clock`` - Current time in ``HH:MM:SS`` format * ``cwd`` - Current working directory including full folder hierarchy (c.f. ``wd``\ ) +* ``gcloud`` - Current gcloud active account * ``hostname`` - Host name of machine * ``in_toolbox`` - Show identifier if running inside a `toolbox `_ * ``in_vim`` - Show identifier if running in ``:terminal`` from vim diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 3030595738..e84cc29122 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -188,6 +188,12 @@ function terraform_workspace_prompt { fi } +function active_gcloud_account_prompt { + if _command_exists gcloud; then + echo -e "$(gcloud config list account --format "value(core.account)" 2> /dev/null)" + fi +} + function git_prompt_minimal_info { SCM_STATE=${SCM_THEME_PROMPT_CLEAN} diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index a86eac3cbd..a1663e6f1b 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -91,6 +91,9 @@ HISTORY_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_HISTORY_NUMBER_CHAR:="#"} COMMAND_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_COMMAND_NUMBER_COLOR:=0} COMMAND_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_COMMAND_NUMBER_CHAR:="#"} +GCLOUD_THEME_PROMPT_COLOR=${POWERLINE_GCLOUD_COLOR:=161} +GCLOUD_CHAR=${POWERLINE_GCLOUD_CHAR:="❲G❳ "} + POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby node cwd"} POWERLINE_RIGHT_PROMPT=${POWERLINE_RIGHT_PROMPT:="in_vim clock battery user_info"} diff --git a/themes/powerline-naked/powerline-naked.theme.bash b/themes/powerline-naked/powerline-naked.theme.bash index 7a5bd4ed74..417ae71a83 100644 --- a/themes/powerline-naked/powerline-naked.theme.bash +++ b/themes/powerline-naked/powerline-naked.theme.bash @@ -86,6 +86,9 @@ HISTORY_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_HISTORY_NUMBER_CHAR:="#"} COMMAND_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_COMMAND_NUMBER_COLOR:=254} COMMAND_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_COMMAND_NUMBER_CHAR:="#"} +GCLOUD_THEME_PROMPT_COLOR=${POWERLINE_GCLOUD_COLOR:=161} +GCLOUD_CHAR=${POWERLINE_GCLOUD_CHAR:="❲G❳ "} + POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"} safe_append_prompt_command __powerline_prompt_command diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index b2a290a518..0b8f4f5661 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -83,6 +83,9 @@ HISTORY_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_HISTORY_NUMBER_CHAR:="#"} COMMAND_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_COMMAND_NUMBER_COLOR:=0} COMMAND_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_COMMAND_NUMBER_CHAR:="#"} +GCLOUD_THEME_PROMPT_COLOR=${POWERLINE_GCLOUD_COLOR:=161} +GCLOUD_CHAR=${POWERLINE_GCLOUD_CHAR:="❲G❳ "} + POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"} safe_append_prompt_command __powerline_prompt_command diff --git a/themes/powerline/powerline.base.bash b/themes/powerline/powerline.base.bash index dd39337ea2..43ee8be113 100644 --- a/themes/powerline/powerline.base.bash +++ b/themes/powerline/powerline.base.bash @@ -49,6 +49,13 @@ function __powerline_terraform_prompt() { fi } +function __powerline_gcloud_prompt() { + local active_gcloud_account="" + + active_gcloud_account="$(active_gcloud_account_prompt)" + [[ -n "${active_gcloud_account}" ]] && echo "${GCLOUD_CHAR}${active_gcloud_account}|${GCLOUD_THEME_PROMPT_COLOR}" +} + function __powerline_node_prompt() { local node_version="" diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index 3239b360f2..794121b887 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -88,6 +88,9 @@ HISTORY_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_HISTORY_NUMBER_CHAR:="#"} COMMAND_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_COMMAND_NUMBER_COLOR:=0} COMMAND_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_COMMAND_NUMBER_CHAR:="#"} +GCLOUD_THEME_PROMPT_COLOR=${POWERLINE_GCLOUD_COLOR:=161} +GCLOUD_CHAR=${POWERLINE_GCLOUD_CHAR:="❲G❳ "} + POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"} safe_append_prompt_command __powerline_prompt_command