diff --git a/fish/config/functions/fish_right_prompt.fish b/fish/config/functions/fish_right_prompt.fish index c622615..c10733a 100644 --- a/fish/config/functions/fish_right_prompt.fish +++ b/fish/config/functions/fish_right_prompt.fish @@ -1,16 +1,11 @@ function fish_right_prompt - set s $status - if test $CMD_DURATION -a -n "$WINDOWID" - # Check if terminal window is hidden + set s $status + test -z $CMD_DURATION -o \( $CMD_DURATION -lt 3000 \) && return + test -z $WINDOWID && return set active_window (xdotool getactivewindow 2>/dev/null) - if [ "$active_window" != "$WINDOWID" ] - # Show notification if dration is more than 30 seconds - if test $CMD_DURATION -gt 3000 - # Show duration of the last command in seconds - 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 + test $active_window -eq $WINDOWID && return + set duration (math $CMD_DURATION / 1000)s + set message (history --max=1) [$duration] + notify-send (test "$s" -ne 0 && echo '--icon' error) $message end