Skip to content

Instantly share code, notes, and snippets.

@rummelonp
Created October 24, 2013 09:12
Show Gist options
  • Save rummelonp/7133834 to your computer and use it in GitHub Desktop.
Save rummelonp/7133834 to your computer and use it in GitHub Desktop.
実行に30秒以上かかった時通知センターに通知するやつ
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