summaryrefslogtreecommitdiff
path: root/.config/fish/functions/_tide_item_context.fish
blob: 575c438cf25d5062aec01da0cb39e7256d9c85d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function _tide_item_context
    if set -q SSH_TTY
        set -lx tide_context_color $tide_context_color_ssh
        test "$tide_context_hostname_parts" = 0 && _tide_print_item context $USER ||
            h=(string split . $hostname) _tide_print_item context $USER@(string join . $h[..$tide_context_hostname_parts])
    else if test "$EUID" = 0
        set -lx tide_context_color $tide_context_color_root
        test "$tide_context_hostname_parts" = 0 && _tide_print_item context $USER ||
            h=(string split . $hostname) _tide_print_item context $USER@(string join . $h[..$tide_context_hostname_parts])
    else if test "$tide_context_always_display" = true
        set -lx tide_context_color $tide_context_color_default
        test "$tide_context_hostname_parts" = 0 && _tide_print_item context $USER ||
            h=(string split . $hostname) _tide_print_item context $USER@(string join . $h[..$tide_context_hostname_parts])
    end
end