Skip to content

Instantly share code, notes, and snippets.

@yuki-takeichi
Last active August 16, 2016 07:45
Show Gist options
  • Save yuki-takeichi/1c50c7e510c15f834e798013b9312107 to your computer and use it in GitHub Desktop.
Save yuki-takeichi/1c50c7e510c15f834e798013b9312107 to your computer and use it in GitHub Desktop.
Notify elapsed seconds when command is finished
#!/bin/bash
# Notify elapsed seconds when command is finished
# (Mac OS X only)
# How to setup:
# 1. `brew install terminal-notifier`
# 2. Put this file in your /bin dir
# How to use:
# `notify sleep 2`
#
# ( See what happens after 2 seconds ;) )
START=$(date +%s)
$@
RET=$?
END=$(date +%s)
ELAPSED=$(($END - $START))
if [ $? -eq 0 ]; then
terminal-notifier -title '🎉' -message "$ELAPSED sec"
else
terminal-notifier -title '❌' -message "$ELAPSED sec"
fi
@yuki-takeichi
Copy link
Author

yuki-takeichi commented Jun 14, 2016

FIXME:

notify cat hoge\ foo.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment