fish: prompt changes

This commit is contained in:
dogeystamp 2023-01-20 19:44:11 -05:00
parent 92c2c15d9f
commit 69915c06fe
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
3 changed files with 39 additions and 0 deletions

View File

@ -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 ""

View File

@ -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

View File

@ -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