From cb958c0da3ce22541795f98a6429c87486531be7 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sun, 23 Aug 2020 12:07:26 +0000 Subject: [PATCH] Include user in prompt if not the normal user --- fish/config.fish | 2 ++ fish/functions/fish_prompt.fish | 7 ++++--- fish/functions/prompt_user.fish | 5 +++++ zshrc | 7 ++++++- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 fish/functions/prompt_user.fish diff --git a/fish/config.fish b/fish/config.fish index 0ea77d8..c011991 100644 --- a/fish/config.fish +++ b/fish/config.fish @@ -23,6 +23,8 @@ set -g fish_color_valid_path normal set -g fish_color_vcs 43d696 set -g fish_color_vcs_braces 29bc7d +set -g fish_normal_user js + test -n "$XDG_CONFIG_HOME" or set -x XDG_CONFIG_HOME $HOME/.config test -n "$XDG_CACHE_HOME" diff --git a/fish/functions/fish_prompt.fish b/fish/functions/fish_prompt.fish index 0e3b11a..449de48 100644 --- a/fish/functions/fish_prompt.fish +++ b/fish/functions/fish_prompt.fish @@ -21,7 +21,8 @@ function fish_prompt --description 'Write out the prompt' (set_color $fish_color_vcs_braces)")" end - echo -n -s (set_color $fish_color_host) (prompt_hostname) ' ' \ - (set_color $fish_color_cwd) (prompt_pwd) (string join '' $vcs) \ - (set_color $fish_color_suffix) $suffix (set_color normal) ' ' + echo -n -s (set_color $fish_color_host) (prompt_user) (prompt_hostname) \ + ' ' (set_color $fish_color_cwd) (prompt_pwd) \ + (string join '' $vcs) (set_color $fish_color_suffix) $suffix \ + (set_color normal) ' ' end diff --git a/fish/functions/prompt_user.fish b/fish/functions/prompt_user.fish new file mode 100644 index 0000000..3cab0df --- /dev/null +++ b/fish/functions/prompt_user.fish @@ -0,0 +1,5 @@ +function prompt_user + if test (whoami) != "$fish_normal_user" + echo (whoami)"@" + end +end diff --git a/zshrc b/zshrc index f34e282..b2b1797 100644 --- a/zshrc +++ b/zshrc @@ -14,6 +14,7 @@ local ls="" local ls_color="auto" local ls_on_cd="yes" local ls_on_init="no" +local normal_user="js" if [ "$COLORTERM" = "24bit" -o "$COLORTERM" = "truecolor" \ -o "$terminfo[colors]" = 16777216 ]; then @@ -99,7 +100,11 @@ set_prompt() { branch+="%F{$color_vcs_braces})" fi - PS1="%F{$color_host}%m %F{$color_cwd}%c$branch" + if [ "$(whoami)" != "$normal_user" ]; then + local user="%n@" + fi + + PS1="%F{$color_host}$user%m %F{$color_cwd}%c$branch" PS1+="%F{$color_suffix}%(!.#.>)%f " PS2="%B>%b " RPS1="%(1j.%F{$color_jobs}%B%j%b%f.)%(?..%(1j. .)"