aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2015-07-19 22:15:26 +0300
committerBen Hilburn <bhilburn@gmail.com>2015-07-19 22:15:26 +0300
commit97cd46a347ba3c07d2bbdacfc1b7c8d54278836a (patch)
treec33260ff370a0112c5aade5e2b1d22866c01a79e
parent1f69d67c2a9802d00bc6e0f89c06175376c4de71 (diff)
parenteed0c842735d8fe40e024dfd05ac09824f4fc6b2 (diff)
Merge pull request #58 from dritter/dritter/customizable_context
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 fd0e3ecd..bef1820a 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
}