MENU

mac 配置编译成功弹窗通知

February 4, 2022 • 鼓捣其他东西

  1. 前言

    之前也有想过这个功能,感觉确实很好玩。当在mac上编译一个大型软件时(如LLVM),往往需要很长时间如果一直盯着命令行就会影响到使用者“多线程”工作的效率。设置通知就可以直接最小化终端。

  2. 安装terminal-notifier

    在MAC OS 10.8版本以上的电脑中,可以使用terminal-notifier通过自己向通知中心发送通知。更多的信息可以参考 https://github.com/julienXX/terminal-notifier。使用brew安装:

    brew install terminal-notifier
  3. 给terminal-notifier设置别名

    ~/.bashrc的最后设置terminal-notifier的别名

    alias notifyDone='terminal-notifier -title "Terminal" -message "Done with task! Exit status: $?"' -activate com.apple.Terminal

    同时还可以设置响铃和消息小红点

    alias notifyDone='tput bel; terminal-notifier -title "Terminal" -message "Done with task! Exit status: $?"' -activate com.apple.Terminal
  4. 使用terminal-notifier

    使用的时候记得手动追加notifyDone命令,像这样

    ninja ; notifyDone

    运行结果: