basyura's blog

あしたになったらほんきだす。

vim から growl

twitvim.vim でリプライがあった場合に growl で通知できたらいいなぁという思いつきで試してみた。vim の ruby サポートを利用して、

vim → ruby → ruby-growl(gem) → growl

で呼び出す。

function s:growl()
ruby <<EOF
require 'ruby-growl'
g = Growl.new "localhost", "ruby-growl", ["ruby-growl Notification"]
g.notify "ruby-growl Notification", "It Came From Ruby-Growl", "Greetings!"
EOF
endfunction

call s:growl()

うまいこといった。最初は meow を試したけど、MacVim のアイコンが Dock にもう一つ現れてぴょんぴょん跳ね続けるし、スクリプトを実行した MacVim 自体が応答なくなって強制終了しないといけないしでダメだった。

ソースの参考

require 'ruby-growl'
g = Growl.new "localhost", "ruby-growl", ["ruby-growl Notification"]
g.notify "ruby-growl Notification", "It Came From Ruby-Growl", "Greetings!"
uneval in JavaScript shell, Keycastr, ruby-growl, Maglev and Rubinius

Growl のネットワーク設定の参考

Here’s how to fix that on OS X 10.5
1. Go to System Preferences and click Growl
2. Choose Network
3. Check ‘Listen for incoming notifications’
4. Check ‘Allow remote application registration’. Don’t worry about setting a password for now.
5. Run the above script and you should see a Growl alert
6. You should now be able to uncheck ‘Allow remote application registration’ and it will still work
Getting ruby-growl to work