From 532e8e46458ace494ceaf43d5207fbb59743d43b Mon Sep 17 00:00:00 2001 From: Aaron Burchfield Date: Tue, 24 Mar 2015 16:08:12 -0700 Subject: [PATCH] Update bgnotify.plugin.zsh Return to terminal app by clicking on notification. Supports iTerm and Terminal for now. --- plugins/bgnotify/bgnotify.plugin.zsh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh index 14ca4c817..ac4d006e0 100755 --- a/plugins/bgnotify/bgnotify.plugin.zsh +++ b/plugins/bgnotify/bgnotify.plugin.zsh @@ -29,9 +29,20 @@ currentWindowId () { fi } +terminalBundleID () { + if [[ $TERM_PROGRAM == iTerm.app ]]; then + terminal_id=$(osascript -e 'id of app "iTerm.app"') + elif [[ $TERM_PROGRAM == Apple_Terminal ]]; then + terminal_id=$(osascript -e 'id of app "Terminal.app"') + fi + if [ ! -z $terminal_id ]; then + echo $terminal_id + fi +} + bgnotify () { if hash terminal-notifier 2>/dev/null; then #osx - terminal-notifier -message "$2" -title "$1" + terminal-notifier -message "$2" -title "$1" -activate "$(terminalBundleID)" elif hash growlnotify 2>/dev/null; then #osx growl growlnotify -m $1 $2 elif hash notify-send 2>/dev/null; then #ubuntu!