From bd5dd93420f02896d313730196e334255d28ca25 Mon Sep 17 00:00:00 2001 From: Yi-Ting Shih Date: Sat, 12 Apr 2025 18:30:53 +0800 Subject: [PATCH] Feat: change hostname color when ssh --- functions/fish_prompt.fish | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 2a70a1b..d588411 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -19,8 +19,12 @@ function fish_prompt --description 'Informative prompt' set -l git_root_basename (basename "$git_root") set cwd (string replace --regex "^$git_root" "($git_root_basename)" "$cwd") end - printf '[%s] %s%s@%s %s%s%s%s %s %s\n> ' (date "+%H:%M:%S") \ - (set_color brblue) "$USER" (prompt_hostname) \ + set -l hostname_color (set_color brblue) + if test -n $SSH_CLIENT + set hostname_color (set_color magenta) + end + printf '[%s] %s%s@%s%s %s%s%s%s %s %s\n> ' (date "+%H:%M:%S") \ + (set_color brblue) "$USER" "$hostname_color" (prompt_hostname) \ (set_color $fish_color_cwd) "$cwd" \ (set_color yellow) "$(fish_git_prompt)" \ "$pipestatus_string" \