Instead of waiting for long commands to finish one can easily get notifications when they are complete. The following procdure shows how to set his in fish shell.
Requirements: fish shell, notify-send, xdotool
- Add a new file
vi ~/.config/fish/functions/noti.fish
with the content below:
function fish_right_prompt
if test $CMD_DURATION
# Check if terminal window is hidden
if test (xdotool getactivewindow) -ne $WINDOWID
# Show notification if dration is more than 30 seconds
if test $CMD_DURATION -gt 30000
# Show duration of the last command in seconds
set duration (echo "$CMD_DURATION 1000" | awk '{printf "%.3fs", $1 / $2}')
notify-send (echo (history | head -1) returned $status after $duration)
end
end
end
end
- Add the following line at the end of
~/.config/fish/config.fish
to sourcenoti.fish
:
. ~/.config/fish/functions/noti.fish