1
0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-12-12 19:18:28 +02:00

Use SUDO_COMMAND to check for sudo

`sudo -n true` only checks that we _could_ use `sudo`, not if we are in
a sudo session.

closes #852
This commit is contained in:
Christian Höltje 2018-07-31 16:22:26 -04:00
parent 22a761208d
commit 7f6ac8dbac

View File

@ -623,12 +623,12 @@ prompt_context() {
if [[ $(print -P "%#") == '#' ]]; then
current_state="ROOT"
elif [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then
if sudo -n true 2>/dev/null; then
if [[ -n "$SUDO_COMMAND" ]]; then
current_state="REMOTE_SUDO"
else
current_state="REMOTE"
fi
elif sudo -n true 2>/dev/null; then
elif [[ -n "$SUDO_COMMAND" ]]; then
current_state="SUDO"
fi