Closed 8bitgentleman closed 7 years ago
So, it takes a bit of experimentation to get it to do precisely what you want, depending on context.
terminal-notifier -title "Title" -message "Message" -actions "Close" -execute "open ~/"
In this example, the -execute
switch will run the command when the message is clicked. The command open ~/SomeDir
will open the directory in Finder (you can also do something like open /Applications/TextEdit.app ~/SomeDir/SomeFile.foo
- you get the idea)
As of this writing, this only works if you also include the -actions
switch. If you want to do anything more interesting than "Close" you have to capture the stdin
from it, eg:
#!/bin/bash
function notifier_action {
read action
if [ "$action" = "View Log" ]; then
open /Applications/Utilities/Console.app /var/log/system.log
fi
}
terminal-notifier -title "Title" -message "Message" -actions "View Log" -execute "open ~/" | notifier_action
I added an example actions usage in the README https://github.com/julienXX/terminal-notifier#exemple-actions-usage-with-a-shell-script-and-jq
Is it possible to open a certain folder or file when the notification is clicked?