1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-16 17:50:09 +00:00

add sudo status to context and user prompts

This commit is contained in:
Michael Louwrens 2018-02-10 19:46:31 +02:00
parent fd3d234354
commit 7b8656f8e7

View file

@ -590,6 +590,7 @@ prompt_context() {
typeset -AH context_states typeset -AH context_states
context_states=( context_states=(
"ROOT" "yellow" "ROOT" "yellow"
"SUDO" "yellow"
"DEFAULT" "yellow" "DEFAULT" "yellow"
"REMOTE" "yellow" "REMOTE" "yellow"
) )
@ -608,6 +609,8 @@ prompt_context() {
current_state="ROOT" current_state="ROOT"
elif [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then elif [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then
current_state="REMOTE" current_state="REMOTE"
elif sudo -n uptime >/dev/null 2>&1; then
current_statue="SUDO"
fi fi
"$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}" "$1_prompt_segment" "${0}_${current_state}" "$2" "$DEFAULT_COLOR" "${context_states[$current_state]}" "${content}"
@ -629,6 +632,14 @@ prompt_user() {
"FOREGROUND_COLOR" "yellow" "FOREGROUND_COLOR" "yellow"
"VISUAL_IDENTIFIER" "ROOT_ICON" "VISUAL_IDENTIFIER" "ROOT_ICON"
) )
elif sudo -n uptime >/dev/null 2>&1; then
user_state=(
"STATE" "SUDO"
"CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}"
"BACKGROUND_COLOR" "${DEFAULT_COLOR}"
"FOREGROUND_COLOR" "yellow"
"VISUAL_IDENTIFIER" "ROOT_ICON"
)
else else
user_state=( user_state=(
"STATE" "DEFAULT" "STATE" "DEFAULT"