Blog | Phodal - A Growth Engineerhttp://www.phodal.com/blog/2014-05-14T04:07:41.074697+00:00Blogmac os terminal notifier 用terminal-notifier替代growl2014-04-22T13:18:36+00:002014-05-14T04:07:41.074697+00:00Phodal Huanghttp://www.phodal.com/blog/author/root/http://www.phodal.com/blog/mac-os-use-terminal-notifier-repace-growl-with-iterm2/本来想找一个Notifier用来提示terminal状态的软件,只是除了``growl``之外,似乎没有一个好的方案,直到偶然间看到了``terminal-notifier``。
##Terminal Notifier
> terminal-notifier is a command-line tool to send Mac OS X User Notifications, which are available in Mac OS X 10.8 and higher.
Terminal Notifier 是一个命令行工具用来当Mac OS X的用户提醒。谁让``Growl``是收费的,还没有试用。
##下载Terminal Notifier
Terminal Notifier下载地址
[https://github.com/alloy/terminal-notifier/releases](https://github.com/alloy/terminal-notifier/releases)
如果是用``Ruby``的话可以这样安装
gem install terminal-notifier
只是相对于用gem这类,需要``rvm``之类的来说,``Homebrew``会是一个更好的方案
brew install terminal-notifier
##Mac OS Notifier
Terminal Notifier用法
$ terminal-notifier -[message|group|list] [VALUE|ID|ID] [options]
官方给了几个示例
$ echo 'Piped Message Data!' | terminal-notifier -sound default
$ terminal-notifier -title '💰' -message 'Check your Apple stock!' -open 'http://finance.yahoo.com/q?s=AAPL'
$ terminal-notifier -group 'address-book-sync' -title 'Address Book Sync' -subtitle 'Finished' -message 'Imported 42 contacts.' -activate 'com.apple.AddressBook'
至于 '💰' 这个神奇的符号是Mac OS专用的,其他的可能看不到。
于是就有了这样一个自己的配置。
terminal-notifier -sound default -title '' -message "Happy Hacking!!"
至于这个苹果的起源。。据说可以用快捷键``Alt + Shift + K ``,至于``Happy Hacking``这个写法是来自于``emacs``的,
<h4 style="font-size:45.2px;"></h4>
![Happy Hacking][1]
##Terminal Notifier替换Growl
修改``.bash_profile``
function growl() {
terminal-notifier -activate com.googlecode.iterm2 -title '' -subtitle "A message from your shell:" -message "$@"
}
下面这个是用于语音提醒
function groooowl() {
terminal-notifier -activate com.googlecode.iterm2 -title '' -subtitle "A message from your shell:" -message "$@"
say "$@"
}
[1]: /static/media/uploads/screen_shot_2014-04-22_at_9.31.32_pm.png