fish shell で長いコマンドが終わったら通知センターに知らせる
注意
$CMD_DURATION
のフォーマットの都合上、version 2.2.0 より古い fish では動かない。
通知センターに push する function
~/.config/fish/functions/fish_notify.fish
function fish_notify
echo "display notification \"$argv[2]\" with title \"$argv[1]\"" | osascript
end
fish_prompt から呼ぶ
~/.config/fish/functions/fish_prompt.fish
function fish_prompt --description 'Write out the prompt'
(...)
# 10 秒以上かかったコマンドを通知する
if test $CMD_DURATION
if test $CMD_DURATION -gt (math "1000 * 10")
set secs (math "$CMD_DURATION / 1000")
fish_notify "$history[1]" "Returned $status, took $secs seconds"
end
end
end