nix-infra/files/config/fish/functions/fish_right_prompt.fish

33 lines
1.1 KiB
Fish
Raw Normal View History

2024-03-24 18:02:26 +00:00
function fish_right_prompt
set -g __fish_git_prompt_showdirtystate 1
set -g __fish_git_prompt_showuntrackedfiles 1
set -g __fish_git_prompt_showupstream informative
set -g __fish_git_prompt_showcolorhints 1
set -g __fish_git_prompt_use_informative_chars 1
# Unfortunately this only works if we have a sensible locale
string match -qi "*.utf-8" -- $LANG $LC_CTYPE $LC_ALL
and set -g __fish_git_prompt_char_dirtystate \U1F4a9
set -g __fish_git_prompt_char_untrackedfiles "?"
# The git prompt's default format is ' (%s)'.
# We don't want the leading space.
set -l vcs (fish_vcs_prompt '(%s)' 2>/dev/null)
set -l d (set_color brgrey)(date "+%R")(set_color normal)
set -l duration "$cmd_duration$CMD_DURATION"
if test $duration -gt 100
set duration (math $duration / 1000)s
else
set duration
end
set -q VIRTUAL_ENV_DISABLE_PROMPT
or set -g VIRTUAL_ENV_DISABLE_PROMPT true
set -q VIRTUAL_ENV
and set -l venv (string replace -r '.*/' '' -- "$VIRTUAL_ENV")
set_color normal
string join " " -- $venv $duration $vcs $d
end