aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rwxr-xr-xfunctions/icons.zsh5
-rwxr-xr-xpowerlevel9k.zsh-theme24
3 files changed, 27 insertions, 5 deletions
diff --git a/README.md b/README.md
index 02defba2..6b516c12 100644
--- a/README.md
+++ b/README.md
@@ -312,7 +312,7 @@ main theme distribution so that everyone can use it!
The `context` segment (user@host string) is conditional. By default, it will
only print if you are not your 'normal' user (including if you are root), or if
-you are SSH'd to a remote host.
+you are SSH'd to a remote host. `SUDO` and `REMOTE_SUDO` states are also available to show whether the current user or remote user has superuser privileges.
To use this feature, make sure the `context` segment is enabled in your prompt
elements (it is by default), and define a `DEFAULT_USER` in your `~/.zshrc`.
@@ -581,6 +581,7 @@ You can also override the icons by setting:
```
POWERLEVEL9K_USER_ICON="\uF415" # 
POWERLEVEL9K_ROOT_ICON="#"
+POWERLEVEL9K_SUDO_ICON=$'\uF09C' # 
```
| Variable | Default Value | Description |
diff --git a/functions/icons.zsh b/functions/icons.zsh
index 33c71ff0..b929f73a 100755
--- a/functions/icons.zsh
+++ b/functions/icons.zsh
@@ -27,6 +27,7 @@ case $POWERLEVEL9K_MODE in
RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' # 
CARRIAGE_RETURN_ICON $'\u21B5' # ↵
ROOT_ICON $'\uE801' # 
+ SUDO_ICON $'\uF09C' # 
RUBY_ICON $'\uE847 ' # 
AWS_ICON $'\uE895' # 
AWS_EB_ICON $'\U1F331 ' # 🌱
@@ -118,6 +119,7 @@ case $POWERLEVEL9K_MODE in
RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' # 
CARRIAGE_RETURN_ICON $'\u21B5' # ↵
ROOT_ICON $'\uF201' # 
+ SUDO_ICON $'\uF09C' # 
RUBY_ICON $'\uF219 ' # 
AWS_ICON $'\uF270' # 
AWS_EB_ICON $'\U1F331 ' # 🌱
@@ -214,6 +216,7 @@ case $POWERLEVEL9K_MODE in
RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' # 
CARRIAGE_RETURN_ICON $'\u21B5' # ↵
ROOT_ICON '\u'$CODEPOINT_OF_OCTICONS_ZAP # 
+ SUDO_ICON '\u'$CODEPOINT_OF_AWESOME_UNLOCK # 
RUBY_ICON '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' # 
AWS_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER # 
AWS_EB_ICON $'\U1F331 ' # 🌱
@@ -298,6 +301,7 @@ case $POWERLEVEL9K_MODE in
RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' # 
CARRIAGE_RETURN_ICON $'\u21B5' # ↵
ROOT_ICON $'\uE614 ' # 
+ SUDO_ICON $'\uF09C' # 
RUBY_ICON $'\uF219 ' # 
AWS_ICON $'\uF270' # 
AWS_EB_ICON $'\UF1BD ' # 
@@ -385,6 +389,7 @@ case $POWERLEVEL9K_MODE in
RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' # 
CARRIAGE_RETURN_ICON $'\u21B5' # ↵
ROOT_ICON $'\u26A1' # ⚡
+ SUDO_ICON $'\uE0A2' # 
RUBY_ICON ''
AWS_ICON 'AWS:'
AWS_EB_ICON $'\U1F331 ' # 🌱
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index c0849a50..3e587717 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -589,9 +589,11 @@ prompt_context() {
local current_state="DEFAULT"
typeset -AH context_states
context_states=(
- "ROOT" "yellow"
- "DEFAULT" "yellow"
- "REMOTE" "yellow"
+ "ROOT" "yellow"
+ "SUDO" "yellow"
+ "DEFAULT" "yellow"
+ "REMOTE" "yellow"
+ "REMOTE_SUDO" "yellow"
)
local content=""
@@ -607,7 +609,13 @@ prompt_context() {
if [[ $(print -P "%#") == '#' ]]; then
current_state="ROOT"
elif [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then
- current_state="REMOTE"
+ if sudo -n true 2>/dev/null; then
+ current_state="REMOTE_SUDO"
+ else
+ current_state="REMOTE"
+ fi
+ elif sudo -n true 2>/dev/null; then
+ current_state="SUDO"
fi
"$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}"
@@ -629,6 +637,14 @@ prompt_user() {
"FOREGROUND_COLOR" "yellow"
"VISUAL_IDENTIFIER" "ROOT_ICON"
)
+ elif sudo -n true 2>/dev/null; then
+ user_state=(
+ "STATE" "SUDO"
+ "CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}"
+ "BACKGROUND_COLOR" "${DEFAULT_COLOR}"
+ "FOREGROUND_COLOR" "yellow"
+ "VISUAL_IDENTIFIER" "SUDO_ICON"
+ )
else
user_state=(
"STATE" "DEFAULT"