Skip to content

Instantly share code, notes, and snippets.

@porglezomp
Last active January 10, 2021 22:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save porglezomp/9e8a57988f322500ed1f76364546bf49 to your computer and use it in GitHub Desktop.
Save porglezomp/9e8a57988f322500ed1f76364546bf49 to your computer and use it in GitHub Desktop.
Send a notification when a long-running command finishes.
# I have this inside my .config/fish/config.fish, but you migh be able to put it in .config/fish/functions ?
function show_notif --on-event fish_postexec
set -l duration $CMD_DURATION
set -l command $argv
if [ $duration -gt 10000 ]
set -l is_front (osascript -e 'tell application "Terminal" to frontmost')
if [ $is_front != "true" ]
osascript -e "display notification \"Command `$command` finished running after "(expr $duration / 1000)"s\" with title \"Command finished\""
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment