LoginSignup
10
9

More than 5 years have passed since last update.

fish shell で長いコマンドが終わったら通知センターに知らせる

Last updated at Posted at 2015-08-13

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

参考

10
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
9