refactor: simplify fish prompt and configs

This commit is contained in:
mitchell 2026-04-13 14:33:48 -04:00
parent fddae3ba36
commit 7da5ead1ed
32 changed files with 139 additions and 1156 deletions

View file

@ -1,18 +1,12 @@
# Some functions borrowed from bobthefish theme (https://github.com/oh-my-fish/theme-bobthefish).
# Copyright (c) 2013-2014 Justin Hileman.
#
# You can override some default right prompt options in your config.fish:
# set -g theme_date_format "+%a %H:%M"
function __bobthefish_cmd_duration -S -d 'Show command duration'
[ "$theme_display_cmd_duration" = "no" ]
and return
[ -z "$CMD_DURATION" -o "$CMD_DURATION" -lt 100 ]
and return
if [ "$CMD_DURATION" -lt 5000 ]
echo -ns $CMD_DURATION 'ms'
echo -ns $CMD_DURATION ms
else if [ "$CMD_DURATION" -lt 60000 ]
__bobthefish_pretty_ms $CMD_DURATION s
else if [ "$CMD_DURATION" -lt 3600000 ]
@ -26,8 +20,7 @@ function __bobthefish_cmd_duration -S -d 'Show command duration'
set_color $fish_color_normal
set_color $fish_color_autosuggestion
[ "$theme_display_date" = "no" ]
or echo -ns ' ' $__bobthefish_left_arrow_glyph
echo -ns ' ' $__bobthefish_left_arrow_glyph
end
function __bobthefish_pretty_ms -S -a ms -a interval -d 'Millisecond formatting for humans'
@ -44,28 +37,13 @@ function __bobthefish_pretty_ms -S -a ms -a interval -d 'Millisecond formatting
set scale 2
end
switch $FISH_VERSION
case 2.0.\* 2.1.\* 2.2.\* 2.3.\*
# Fish 2.3 and lower doesn't know about the -s argument to math.
math "scale=$scale;$ms/$interval_ms" | string replace -r '\\.?0*$' $interval
case 2.\*
# Fish 2.x always returned a float when given the -s argument.
math -s$scale "$ms/$interval_ms" | string replace -r '\\.?0*$' $interval
case \*
math -s$scale "$ms/$interval_ms"
echo -ns $interval
end
math -s$scale "$ms/$interval_ms"
echo -ns $interval
end
function __bobthefish_timestamp -S -d 'Show the current timestamp'
[ "$theme_display_date" = "no" ]
and return
set -q theme_date_format
or set -l theme_date_format "+%c"
echo -n ' '
date $theme_date_format
date "+%c"
end
function fish_right_prompt -d 'bobthefish is all about the right prompt'