Skip to content

Commit 6f02b8d

Browse files
author
Noah Gorny
authored
Merge pull request #1851 from ofirshtrull/master
Add support for active gcloud account in powerline prompt
2 parents c8ef6c9 + 8ae2b1e commit 6f02b8d

File tree

7 files changed

+26
-0
lines changed

7 files changed

+26
-0
lines changed

docs/themes-list/powerline-base.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o
7070
* ``battery`` - Battery information (you'll need to enable the ``battery`` plugin)
7171
* ``clock`` - Current time in ``HH:MM:SS`` format
7272
* ``cwd`` - Current working directory including full folder hierarchy (c.f. ``wd``\ )
73+
* ``gcloud`` - Current gcloud active account
7374
* ``hostname`` - Host name of machine
7475
* ``in_toolbox`` - Show identifier if running inside a `toolbox <https://github.com/containers/toolbox>`_
7576
* ``in_vim`` - Show identifier if running in ``:terminal`` from vim

themes/base.theme.bash

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ function terraform_workspace_prompt {
188188
fi
189189
}
190190

191+
function active_gcloud_account_prompt {
192+
if _command_exists gcloud; then
193+
echo -e "$(gcloud config list account --format "value(core.account)" 2> /dev/null)"
194+
fi
195+
}
196+
191197
function git_prompt_minimal_info {
192198
SCM_STATE=${SCM_THEME_PROMPT_CLEAN}
193199

themes/powerline-multiline/powerline-multiline.theme.bash

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ HISTORY_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_HISTORY_NUMBER_CHAR:="#"}
9191
COMMAND_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_COMMAND_NUMBER_COLOR:=0}
9292
COMMAND_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_COMMAND_NUMBER_CHAR:="#"}
9393

94+
GCLOUD_THEME_PROMPT_COLOR=${POWERLINE_GCLOUD_COLOR:=161}
95+
GCLOUD_CHAR=${POWERLINE_GCLOUD_CHAR:="❲G❳ "}
96+
9497
POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby node cwd"}
9598
POWERLINE_RIGHT_PROMPT=${POWERLINE_RIGHT_PROMPT:="in_vim clock battery user_info"}
9699

themes/powerline-naked/powerline-naked.theme.bash

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ HISTORY_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_HISTORY_NUMBER_CHAR:="#"}
8686
COMMAND_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_COMMAND_NUMBER_COLOR:=254}
8787
COMMAND_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_COMMAND_NUMBER_CHAR:="#"}
8888

89+
GCLOUD_THEME_PROMPT_COLOR=${POWERLINE_GCLOUD_COLOR:=161}
90+
GCLOUD_CHAR=${POWERLINE_GCLOUD_CHAR:="❲G❳ "}
91+
8992
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"}
9093

9194
safe_append_prompt_command __powerline_prompt_command

themes/powerline-plain/powerline-plain.theme.bash

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ HISTORY_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_HISTORY_NUMBER_CHAR:="#"}
8383
COMMAND_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_COMMAND_NUMBER_COLOR:=0}
8484
COMMAND_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_COMMAND_NUMBER_CHAR:="#"}
8585

86+
GCLOUD_THEME_PROMPT_COLOR=${POWERLINE_GCLOUD_COLOR:=161}
87+
GCLOUD_CHAR=${POWERLINE_GCLOUD_CHAR:="❲G❳ "}
88+
8689
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"}
8790

8891
safe_append_prompt_command __powerline_prompt_command

themes/powerline/powerline.base.bash

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ function __powerline_terraform_prompt() {
4949
fi
5050
}
5151

52+
function __powerline_gcloud_prompt() {
53+
local active_gcloud_account=""
54+
55+
active_gcloud_account="$(active_gcloud_account_prompt)"
56+
[[ -n "${active_gcloud_account}" ]] && echo "${GCLOUD_CHAR}${active_gcloud_account}|${GCLOUD_THEME_PROMPT_COLOR}"
57+
}
58+
5259
function __powerline_node_prompt() {
5360
local node_version=""
5461

themes/powerline/powerline.theme.bash

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ HISTORY_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_HISTORY_NUMBER_CHAR:="#"}
8888
COMMAND_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_COMMAND_NUMBER_COLOR:=0}
8989
COMMAND_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_COMMAND_NUMBER_CHAR:="#"}
9090

91+
GCLOUD_THEME_PROMPT_COLOR=${POWERLINE_GCLOUD_COLOR:=161}
92+
GCLOUD_CHAR=${POWERLINE_GCLOUD_CHAR:="❲G❳ "}
93+
9194
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"}
9295

9396
safe_append_prompt_command __powerline_prompt_command

0 commit comments

Comments
 (0)