add dark/light mode via is_dark_mode function, if defined; add clock on right prompt if fish_right_prompt_show_clock is defined

This commit is contained in:
Mark Lowne 2020-02-11 18:28:56 +01:00
parent 8945e30794
commit e61c7cee2a
2 changed files with 32 additions and 6 deletions

View File

@ -3,7 +3,25 @@ function fish_prompt
set -l pwd_info (pwd_info "/") set -l pwd_info (pwd_info "/")
set -l dir set -l dir
set -l base set -l base
set -l base_color 888 161616
set -l dark_mode 1 #default to dark mode
set -l base_color
set -l text_color
set -l split_color
if functions -q is_dark_mode
is_dark_mode; or set -e dark_mode
end
if set -lq dark_mode
set base_color BBB 333
set text_color FFF
# set split_color 000
else
set base_color 555 DDD
set text_color 000
# set split_color FFF
end
set split_color $base_color[2]
if test "$PWD" = ~ if test "$PWD" = ~
set base "~" set base "~"
@ -66,14 +84,14 @@ function fish_prompt
if set -q git_color[3] if set -q git_color[3]
segment "$git_color[3]" "$git_color[4]" "$prompt" segment "$git_color[3]" "$git_color[4]" "$prompt"
segment black black segment $split_color $split_color
segment "$git_color[1]" "$git_color[2]" " $git_glyph " segment "$git_color[1]" "$git_color[2]" " $git_glyph "
else else
segment "$git_color[1]" "$git_color[2]" "$prompt" segment "$git_color[1]" "$git_color[2]" "$prompt"
end end
end end
segment $base_color " $dir"(set_color white)"$base " segment $base_color " $dir"(set_color $text_color)"$base "
if test ! -z "$SSH_CLIENT" if test ! -z "$SSH_CLIENT"
set -l color bbb 222 set -l color bbb 222

View File

@ -1,7 +1,14 @@
function fish_right_prompt function fish_right_prompt
set -l status_copy $status set -l status_copy $status
set -l status_code $status_copy set -l status_code $status_copy
set -l status_color 555
set -l dark_mode 1 #default to dark mode
if functions -q is_dark_mode
is_dark_mode; or set -e dark_mode
end
set -l status_color 333; set -lq dark_mode; or set status_color DDD
set -l status_glyph set -l status_glyph
set -l duration_glyph set -l duration_glyph
@ -34,6 +41,7 @@ function fish_right_prompt
set status_glyph set status_glyph
end end
end end
echo -sn (set_color $status_color)
echo -sn (set_color $status_color) "$status_glyph" (set_color normal) set -q fish_right_prompt_show_clock; and echo -sn (date "+%H:%M:%S")" "
echo -sn "$status_glyph" (set_color normal)
end end