home-config/fish/functions/_tide_item_context.fish
6cc18a0d63f5494aee56f17d3b422d53993f8ab3
· 475 B · 14 lines
raw
| 1 | function _tide_item_context |
| 2 | if set -q SSH_TTY |
| 3 | set -fx tide_context_color $tide_context_color_ssh |
| 4 | else if test "$EUID" = 0 |
| 5 | set -fx tide_context_color $tide_context_color_root |
| 6 | else if test "$tide_context_always_display" = true |
| 7 | set -fx tide_context_color $tide_context_color_default |
| 8 | else |
| 9 | return |
| 10 | end |
| 11 | |
| 12 | string match -qr "^(?<h>(\.?[^\.]*){0,$tide_context_hostname_parts})" @$hostname |
| 13 | _tide_print_item context $USER$h |
| 14 | end |