dotfiles/.config/fish/functions/fish_right_prompt.fish

57 lines
1.5 KiB
Fish

# Some functions borrowed from bobthefish theme (https://github.com/oh-my-fish/theme-bobthefish).
# Copyright (c) 2013-2014 Justin Hileman.
function __bobthefish_cmd_duration -S -d 'Show command duration'
[ -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
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
math -s$scale "$ms/$interval_ms"
echo -ns $interval
end
function __bobthefish_timestamp -S -d 'Show the current timestamp'
echo -n ' '
date "+%c"
end
function fish_right_prompt -d 'bobthefish is all about the right prompt'
set __bobthefish_left_arrow_glyph '<'
set_color $fish_color_autosuggestion
__bobthefish_cmd_duration
__bobthefish_timestamp
set_color normal
end