37 lines
978 B
Fish
37 lines
978 B
Fish
function fish_command_timer_compute_cmd_duration_str
|
|
if [ $CMD_DURATION -lt 10000 ]
|
|
return
|
|
end
|
|
|
|
set -l SEC 1000
|
|
set -l MIN 60000
|
|
set -l HOUR 3600000
|
|
set -l DAY 86400000
|
|
|
|
set -l num_days (math -s0 "$CMD_DURATION / $DAY")
|
|
set -l num_hours (math -s0 "$CMD_DURATION % $DAY / $HOUR")
|
|
set -l num_mins (math -s0 "$CMD_DURATION % $HOUR / $MIN")
|
|
set -l num_secs (math -s0 "$CMD_DURATION % $MIN / $SEC")
|
|
set -l cmd_duration_str ""
|
|
if [ $num_days -gt 0 ]
|
|
set cmd_duration_str {$cmd_duration_str}{$num_days}"d "
|
|
end
|
|
if [ $num_hours -gt 0 ]
|
|
set cmd_duration_str {$cmd_duration_str}{$num_hours}"h "
|
|
end
|
|
if [ $num_mins -gt 0 ]
|
|
set cmd_duration_str {$cmd_duration_str}{$num_mins}"m "
|
|
end
|
|
set cmd_duration_str {$cmd_duration_str}{$num_secs}s
|
|
printf '%s ' $cmd_duration_str
|
|
end
|
|
|
|
function fish_right_prompt
|
|
set_color brblack
|
|
fish_command_timer_compute_cmd_duration_str
|
|
|
|
set_color green
|
|
printf '%s ' (prompt_pwd)
|
|
set_color normal
|
|
end
|