Get an alert on Mac when a terminal command finishes.
Put drip run in front of any command: it runs it, times it, and shows a green card from your Mac's notch on exit 0, or a red one with the exit code otherwise. drip then exits with the command's own status, so scripts and && chains work as before.
brew install jrnxf/tap/drip
drip run make test
drip run npm run build
drip run --open "$CI_URL" --button "View run" ./deploy.sh
drip is a free, open-source command-line tool for macOS 13 or newer. The card grows out of the camera notch, or out of the top edge of a screen without one, and needs no permissions.
How it works
- The command runs as usual. drip passes its stdin, stdout and stderr straight through.
- The card says how it went. Exit 0 shows
make test finishedin green; anything else showsmake test failed (exit 2)in red. The detail is how long it took, such as3m 12s. - drip's options come first, as for
timeornice:drip run -s 8 make testkeeps the card up for 8 seconds.--before the command also works. - The exit code is the command's. 127 when it is not found; Ctrl-C ends drip with the same signal, so the script that ran it stops too.
- In a script, call drip directly for your own words:
./backup.sh && drip ok "backup done" || drip fail "backup failed".
Without typing drip run
drip setup zsh adds a block to ~/.zshrc that shows the same card for any command that ran 10 seconds or more. It shows only when you are not looking at that terminal, and never for an editor, ssh, less, top or a REPL. A fast command starts no drip at all.
drip setup zsh
exec zsh
export DRIP_SLOW_AFTER=30 # in ~/.zshrc: seconds before a card
DRIP_SLOW_AFTER sets the seconds (0 turns the cards off) and DRIP_SLOW_IGNORE adds commands to leave out. To remove it, delete the block between # >>> drip and # <<< drip <<< from ~/.zshrc. fish is not supported yet.
FAQ
How is this different from osascript's display notification?
osascript -e 'display notification "done"' posts to Notification Center, under Script Editor's name and settings, and knows nothing about the command. drip run shows a card at the notch that says whether the command passed, its exit code and how long it took. See drip vs terminal-notifier, osascript and alerter.
Does drip slow the command down?
No. drip run exits as soon as the command ends; the card plays out on its own. A plain drip ok "done" returns at once.
Can the card link to the CI run or the log?
Yes: --open adds a button that opens a URL or a file, and --button names it, as in drip run --open "$CI_URL" --button "View run" ./deploy.sh.
Can it ask before the next step runs?
Yes. drip warn "Deploy to prod?" --yes Deploy --no Cancel && ./deploy.sh waits for a click: drip exits 0 on yes, 1 on no and 5 when nobody answers.
Can I get a card for every slow command without typing drip run?
Yes, in zsh: drip setup zsh adds a block to ~/.zshrc that shows the card for any command that ran 10 seconds or more, unless you are looking at that terminal. DRIP_SLOW_AFTER changes the 10 seconds.
Does it work over ssh or on Linux?
No. drip needs a Mac running macOS 13 or newer with someone logged in to the screen; over ssh there is no GUI session, so drip exits 3.