From 862c170a062348339eea0e0c714ab3dfab3ae084 Mon Sep 17 00:00:00 2001 From: gzagatti Date: Thu, 11 May 2023 19:49:47 +0800 Subject: [PATCH] uses different PS1 color when on server --- shells/bashrc | 12 ++++++++++-- shells/zshrc | 14 +++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/shells/bashrc b/shells/bashrc index d814ba3..5b0d0a5 100644 --- a/shells/bashrc +++ b/shells/bashrc @@ -209,10 +209,18 @@ if [[ $- == *i* ]]; then local color="" local reset_color=' ' if [[ $THEME == "leuven" ]]; then - color='$(if [[ $? == 0 ]]; then echo "\[\e[48:5:11m\]";else echo "\[\e[38:5:1m\]\[\e[48:5:9m\]"; fi)' + if [[ -n $SSH_CLIENT ]]; then + color='$(if [[ $? == 0 ]]; then echo "\[\e[47:5:10m\]";else echo "\[\e[38:5:1m\]\[\e[48:5:9m\]"; fi)' + else + color='$(if [[ $? == 0 ]]; then echo "\[\e[48:5:11m\]";else echo "\[\e[38:5:1m\]\[\e[48:5:9m\]"; fi)' + end reset_color='\[\e[0m\] ' elif [[ $THEME == "dracula" ]]; then - color='$(if [[ $? == 0 ]]; then echo "\[\e[00;30m\]";else echo "\[\e[00;31m\]"; fi)' + if [[ -n $SSH_CLIENT ]]; then + color='$(if [[ $? == 0 ]]; then echo "\[\e[00;32m\]";else echo "\[\e[00;31m\]"; fi)' + else + color='$(if [[ $? == 0 ]]; then echo "\[\e[00;30m\]";else echo "\[\e[00;31m\]"; fi)' + end reset_color='\[\e[0m\] \[\e[33m\]' fi printf %s "$color$(_precmd_ps1)$info$reset_color" diff --git a/shells/zshrc b/shells/zshrc index 2331094..8d3c3e3 100644 --- a/shells/zshrc +++ b/shells/zshrc @@ -238,10 +238,18 @@ if [[ $- == *i* ]]; then # https://zsh.sourceforge.io/Doc/Release/Prompt-Expansion.html#Visual-effects color="" if [[ $THEME == "leuven" ]]; then - color='%(?.%K{11}.%K{9}%F{1})' + if [[ -n $SSH_CLIENT ]]; then + color='%(?.%K{10}.%K{9}%F{1})' + else + color='%(?.%K{11}.%K{9}%F{1})' + fi LS_COLORS="no=00:fi=00:di=34::ln=32;102:so=37;107:pi=1;33:ex=31:bd=37;107:cd=37;107:su=37;107:sg=37;107:tw=35:ow=35" elif [[ $THEME == "dracula" ]]; then - color='%(?.%F{black}.%F{red})' + if [[ -n $SSH_CLIENT ]]; then + color='%(?.%F{green}.%F{red})' + else + color='%(?.%F{black}.%F{red})' + fi LS_COLORS="no=00:fi=00:di=34::ln=32:so=37:pi=1;33:ex=31:bd=37:cd=37:su=37:sg=37:tw=35:ow=35" fi local host_info_msg="[%m %n]:%1~ %#" @@ -279,7 +287,7 @@ if [[ $- == *i* ]]; then if [[ $THEME = "leuven" ]]; then PS1="$color${dev_info_msg}${host_info_msg}%k%f " elif [[ $THEME = "dracula" ]]; then - PS1="$color${dev_info_msg}${host_info_msg}%F{yellow} " + PS1="$color${dev_info_msg}${host_info_msg}%k%f " else PS1="$color${dev_info_msg}${host_info_msg} " fi