aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Ritter <dritter03@googlemail.com>2015-07-19 15:32:13 +0300
committerDominik Ritter <dritter03@googlemail.com>2015-07-19 15:32:13 +0300
commiteed0c842735d8fe40e024dfd05ac09824f4fc6b2 (patch)
tree0fe58b54fa78a795e31714d8246ade737bf87f15
parent83584894703039a4337b1f7d7b969992ea4cb9c9 (diff)
Made the `context` segment customizable.
-rw-r--r--README.md8
-rw-r--r--powerlevel9k.zsh-theme7
2 files changed, 13 insertions, 2 deletions
diff --git a/README.md b/README.md
index e38b04b4..53c8f482 100644
--- a/README.md
+++ b/README.md
@@ -366,7 +366,13 @@ of the `time` segment, you would use:
Use the segment names from the above section `Segment Customization`. Some of
the Segments have special color variables, as they change the colors according
-to some internal rules. These Segments are `vcs`, `rspec_stats`, `symfony2_tests`:
+to some internal rules. These Segments are `context`, `vcs`, `rspec_stats`, `symfony2_tests`:
+
+ # Colors for root and other users:
+ POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND="green"
+ POWERLEVEL9K_CONTEXT_DEFAULT_FOREGROUND="cyan"
+ POWERLEVEL9K_CONTEXT_ROOT_BACKGROUND="red"
+ POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND="blue"
# General VCS color segments:
POWERLEVEL9K_VCS_FOREGROUND='blue'
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 4f75e89b..8677ac4a 100644
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -437,7 +437,12 @@ prompt_aws() {
# Note that if $DEFAULT_USER is not set, this prompt segment will always print
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
- $1_prompt_segment "$0" "$DEFAULT_COLOR" "011" "%(!.%{%F{yellow}%}.)$USER@%m"
+ if [[ $(print -P "%#") == '#' ]]; then
+ # Shell runs as root
+ $1_prompt_segment "$0_ROOT" "$DEFAULT_COLOR" "yellow" "$USER@%m"
+ else
+ $1_prompt_segment "$0_DEFAULT" "$DEFAULT_COLOR" "011" "$USER@%m"
+ fi
fi
}