summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2018-03-07 05:18:05 +0300
committerGitHub <noreply@github.com>2018-03-07 05:18:05 +0300
commitcfbbd213cb11b86df7517785c2d21037ea2dc9e2 (patch)
treecaab8bc7fb69e0f9108a316cb3298b89cef4f488 /powerlevel9k.zsh-theme
parent6529b4f2a785b0f38355124f1f237b9a8102f283 (diff)
parenta4aacef7bc9663604682ab1afd5e76ef751d546e (diff)
Merge pull request #729 from Mikewl/usersudo
Added sudo state to prompt_user
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme24
1 files changed, 20 insertions, 4 deletions
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"