6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Macでコマンド完了をいい感じに知らせる

Posted at

重いバッチ処理とか回してるときに他の作業してて回してたの忘れがちなので音で知らせたい。

音を鳴らすパターンは以下がいろいろ載っててよい。
bash - コマンドが終了したら音を鳴らしたい - スタック・オーバーフロー

その中のを組み合わせて(個人的に)いい感じにしたのが以下

~/.zshrc
finish () {
    if [ $? -eq 0 ]; then
       afplay /System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/system/burn\ complete.aif
    else
       afplay /System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/system/Volume\ Mount.aif
    fi
}
  • exitステータスで音を切り替え
  • Macにデフォで入ってるシステムサウンドのうち成功っぽいやつと失敗っぽいやつを指定

以下のようにしてコマンドのあとにfinishつけて使う。

$ ruby heavy_process.rb; finish
6
5
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
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?