Created
October 24, 2013 09:12
-
-
Save rummelonp/7133834 to your computer and use it in GitHub Desktop.
実行に30秒以上かかった時通知センターに通知するやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local command="" | |
local command_time="" | |
precmd() { | |
if [ "$command_time" -ne "0" ] ; then | |
local d=`date +%s` | |
d=`expr $d - $command_time` | |
if [ "$d" -ge "30" ] ; then | |
command="$command " | |
notification "$command" -t "${${(s: :)command}[1]}" | |
fi | |
fi | |
command="0" | |
command_time="0" | |
} | |
preexec() { | |
command="${1}" | |
command_time=`date +%s` | |
} | |
function notification() { | |
local title | |
local subtitle | |
local text="" | |
while [ "$1" != "" ]; do | |
case "$1" in | |
-t) | |
shift | |
title="$1" | |
;; | |
-s) | |
shift | |
subtitle="$1" | |
;; | |
*) | |
text+=" $1" | |
esac | |
shift | |
done | |
local command="display notification \"$text\"" | |
if [ -n "$title" ]; then | |
command+=" with title \"$title\"" | |
if [ -n "$subtitle" ]; then | |
command+=" subtitle \"$subtitle\"" | |
fi | |
fi | |
echo "$command" | osascript | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment