[misc] refactoring command finished prompt

This commit is contained in:
Klesh Wong 2020-10-20 11:01:35 +08:00
parent 1745a777c5
commit 67ce079a23

View File

@ -1,16 +1,11 @@
function fish_right_prompt function fish_right_prompt
set s $status set s $status
if test $CMD_DURATION -a -n "$WINDOWID" test -z $CMD_DURATION -o \( $CMD_DURATION -lt 3000 \) && return
# Check if terminal window is hidden test -z $WINDOWID && return
set active_window (xdotool getactivewindow 2>/dev/null) set active_window (xdotool getactivewindow 2>/dev/null)
if [ "$active_window" != "$WINDOWID" ] test $active_window -eq $WINDOWID && return
# Show notification if dration is more than 30 seconds set duration (math $CMD_DURATION / 1000)s
if test $CMD_DURATION -gt 3000 set message (history --max=1) [$duration]
# Show duration of the last command in seconds notify-send (test "$s" -ne 0 && echo '--icon' error) $message
set duration (echo "$CMD_DURATION 1000" | awk '{printf "%.3fs", $1 / $2}')
eval notify-send (test "$s" -ne "0" && echo '--icon' error) "(echo (history | head -1) [$duration])"
end
end
end
end end