Use EUID to detect superuser

This commit is contained in:
Ilan Cosman 2022-07-29 17:49:47 -04:00
parent 132dff77da
commit 6906f7ece2
2 changed files with 3 additions and 3 deletions

View File

@ -1,7 +1,7 @@
function _tide_item_context function _tide_item_context
if set -q SSH_TTY if set -q SSH_TTY
tide_context_color=$tide_context_color_ssh _tide_print_item context $USER@$hostname tide_context_color=$tide_context_color_ssh _tide_print_item context $USER@$hostname
else if contains -- $USER root toor Administrator else if test "$EUID" = 0
tide_context_color=$tide_context_color_root _tide_print_item context $USER@$hostname tide_context_color=$tide_context_color_root _tide_print_item context $USER@$hostname
else if test "$tide_context_always_display" = true else if test "$tide_context_always_display" = true
tide_context_color=$tide_context_color_default _tide_print_item context $USER@$hostname tide_context_color=$tide_context_color_default _tide_print_item context $USER@$hostname

View File

@ -13,5 +13,5 @@ _context # CHECK: {{.*@.*}}
set -g SSH_TTY /dev/pts/0 set -g SSH_TTY /dev/pts/0
_context # CHECK: {{.*@.*}} _context # CHECK: {{.*@.*}}
set USER root set EUID 0
_context # CHECK: {{root@.*}} _context # CHECK: {{.*@.*}}