From db8f37bdb6589d86dce93226fac332b487bbcf10 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 30 Sep 2021 23:51:15 +0200 Subject: [PATCH] Fix fish prompt --- functions/fish_prompt.fish | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index b6cc0a0..0dcb13f 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -36,11 +36,21 @@ function fish_prompt # Hostname - if test -z "$SSH_CLIENT" - set_color green - else - set_color cyan + set -g CURRENT_IP (who am i | awk '{print $5}') + + if test -z "$CURRENT_IP" + # Experiment + set -g CURRENT_IP (who | grep "$USER" | awk '{print $5}') end + + if test "$CURRENT_IP" "=" "(:0)" + set_color green + else if test -n "$SSH_CLIENT" + set_color cyan + else + set_color magenta + end + echo -n (prompt_hostname)