From 69915c06fe50fb73dcf20741d41d79437b51acb1 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Fri, 20 Jan 2023 19:44:11 -0500 Subject: [PATCH] fish: prompt changes --- src/.config/fish/config.fish | 4 +++ src/.config/fish/functions/extra_prompt.fish | 9 +++++++ src/.config/fish/functions/prompts.fish | 26 ++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 src/.config/fish/functions/prompts.fish diff --git a/src/.config/fish/config.fish b/src/.config/fish/config.fish index 23b1201..118da1a 100644 --- a/src/.config/fish/config.fish +++ b/src/.config/fish/config.fish @@ -4,6 +4,7 @@ end source ~/.config/fish/aliases.fish +source ~/.config/fish/functions/prompts.fish source ~/.config/fish/functions/extra_prompt.fish # Set GPG_TTY @@ -17,6 +18,9 @@ set -gx PATH "$PATH:$HOME/.local/bin/minrss-scripts:" set -gx PATH "$PATH:$XDG_DATA_HOME/npm/bin" +# cppman can't set it itself for some reason +set -gx MANPATH "$MANPATH:/home/dogeystamp/.cache/cppman/" + # Disable fish greeting set fish_greeting "" diff --git a/src/.config/fish/functions/extra_prompt.fish b/src/.config/fish/functions/extra_prompt.fish index 3d3fd0b..856bcc5 100644 --- a/src/.config/fish/functions/extra_prompt.fish +++ b/src/.config/fish/functions/extra_prompt.fish @@ -17,3 +17,12 @@ if set -q SSH_AGENT_PID ssha_old_fish_prompt end end + +if set -q SSH_TTY + functions -c fish_prompt ssh_old_fish_prompt + + function fish_prompt + printf "%s%s%s" (set_color 80809C) "(ssh) " (set_color normal) + ssh_old_fish_prompt + end +end diff --git a/src/.config/fish/functions/prompts.fish b/src/.config/fish/functions/prompts.fish new file mode 100644 index 0000000..98af09a --- /dev/null +++ b/src/.config/fish/functions/prompts.fish @@ -0,0 +1,26 @@ +function fish_right_prompt + set -l usercolor (set_color $fish_color_cwd) + if command -sq cksum + # randomised color for user/hostname based on disco.fish + set -l shas (echo $USER@$hostname | cksum | string split -f1 ' ' | math --base=hex | string sub -s 3 | string pad -c 0 -w 6 | string match -ra ..) + set -l col 0x$shas[1..3] + + # ensure luminance is readable + while test (math 0.2126 x $col[1] + 0.7152 x $col[2] + 0.0722 x $col[3]) -lt 120 + set col[1] (math --base=hex "min(255, $col[1] + 60)") + set col[2] (math --base=hex "min(255, $col[2] + 60)") + set col[3] (math --base=hex "min(255, $col[3] + 60)") + end + set -l col (string replace 0x '' $col | string pad -c 0 -w 2 | string join "") + + set usercolor (set_color $col) + end + + printf '%s%s@%s%s' $usercolor \ + (echo $USER | string shorten -m 1 -c '') \ + (echo $hostname | string shorten -m 1 -c '') \ + (set_color normal) +end +function fish_prompt + printf '%s%s%s> ' (set_color blue) (prompt_pwd) (set_color normal) +end