summaryrefslogtreecommitdiffstats
path: root/fish/functions/fish_right_prompt.fish
diff options
context:
space:
mode:
Diffstat (limited to 'fish/functions/fish_right_prompt.fish')
-rw-r--r--fish/functions/fish_right_prompt.fish96
1 files changed, 18 insertions, 78 deletions
diff --git a/fish/functions/fish_right_prompt.fish b/fish/functions/fish_right_prompt.fish
index 45e14d6..14f76ac 100644
--- a/fish/functions/fish_right_prompt.fish
+++ b/fish/functions/fish_right_prompt.fish
@@ -1,80 +1,20 @@
-# See "Right prompt options" in README.md for configuration options
-
-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'
- else if [ "$CMD_DURATION" -lt 60000 ]
- __bobthefish_pretty_ms $CMD_DURATION s
- else if [ "$CMD_DURATION" -lt 3600000 ]
- set_color $fish_color_error
- __bobthefish_pretty_ms $CMD_DURATION m
- else
- set_color $fish_color_error
- __bobthefish_pretty_ms $CMD_DURATION h
- end
-
- set_color $fish_color_normal
- set_color $fish_color_autosuggestion
-
- [ "$theme_display_date" = "no" ]
- or echo -ns ' ' $__bobthefish_left_arrow_glyph
-end
-
-function __bobthefish_pretty_ms -S -a ms -a interval -d 'Millisecond formatting for humans'
- set -l interval_ms
- set -l scale 1
-
- switch $interval
- case s
- set interval_ms 1000
- case m
- set interval_ms 60000
- case h
- set interval_ms 3600000
- 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
-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 ' '
- set -q theme_date_timezone
- and env TZ="$theme_date_timezone" date $theme_date_format
- or date $theme_date_format
+function cstar_segment_divide_right
+ set -l from_var "cstar_$argv[1]"
+ set -l from_name "$from_var""_bg"
+ set -l from $$from_name
+ set -l to_var "cstar_$argv[2]"
+ set -l to_name "$to_var""_bg"
+ set -l to $$to_name
+
+ if test -z "$$from_var"
+ return
+ end
+ if test -z "$$to_var"
+ set -f to normal
+ end
+ echo (set_color -b $to $from)\uE0B2(set_color normal)
end
-function fish_right_prompt -d 'bobthefish is all about the right prompt'
- set -l __bobthefish_left_arrow_glyph \uE0B3
- if [ "$theme_powerline_fonts" = "no" -a "$theme_nerd_fonts" != "yes" ]
- set __bobthefish_left_arrow_glyph '<'
- end
-
- set_color $fish_color_autosuggestion
-
- __bobthefish_cmd_duration
- __bobthefish_timestamp
- set_color normal
-end
+function fish_right_prompt --description "The right side of the C-Star prompt"
+ echo -e "$(cstar_segment_divide_right exit_status normal)$cstar_exit_status$(cstar_segment_divide_right command_time exit_status)$cstar_command_time$(cstar_segment_divide_right datetime command_time)$cstar_datetime"
+end \ No newline at end of file