No need for sed fallback, fish expects bc anyway.

+ use fish math wrapper

See #21
pull/25/head
Justin Hileman 8 years ago
parent ebe5e04f9e
commit c54707a136

@ -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]

Loading…
Cancel
Save