diff --git a/fish_right_prompt.fish b/fish_right_prompt.fish index 28db60d..eeccb58 100644 --- a/fish_right_prompt.fish +++ b/fish_right_prompt.fish @@ -7,25 +7,16 @@ function __bobthefish_cmd_duration -S -d 'Show command duration' if [ "$CMD_DURATION" -lt 5000 ] echo -ns $CMD_DURATION 'ms ' else if [ "$CMD_DURATION" -lt 60000 ] - if type -q bc - echo -ns (echo "scale=1;$CMD_DURATION/1000" | bc | sed 's/.0//') 's ' - else - printf '%.1fs ' (awk "BEGIN { print $CMD_DURATION / 1000 }") - end + math "scale=1;$CMD_DURATION/1000" | sed 's/\\.0$//' + echo -ns 's ' else if [ "$CMD_DURATION" -lt 3600000 ] set_color $fish_color_error - if type -q bc - echo -ns (echo "scale=1;$CMD_DURATION/60000" | bc | sed 's/.0//') 'm ' - else - printf '%.1fm ' (awk "BEGIN { print $CMD_DURATION / 60000 }") - end + math "scale=1;$CMD_DURATION/60000" | sed 's/\\.0$//' + echo -ns 'm ' else set_color $fish_color_error - if type -q bc - echo -ns (echo "scale=1;$CMD_DURATION/3600000" | bc | sed 's/.0//') 'h ' - else - printf '%.1fh ' (awk "BEGIN { print $CMD_DURATION / 3600000 }") - end + math "scale=2;$CMD_DURATION/3600000" | sed 's/\\.0$//' + echo -ns 'h ' end set_color $fish_color_autosuggestion[1]