julienXX / terminal-notifier

Send User Notifications on macOS from the command-line.
Other
6.37k stars 330 forks source link

-execute cannot run functions #159

Closed 1-61803 closed 8 years ago

1-61803 commented 8 years ago
$ function safari { open -a safari ; }
$ terminal-notifier -message safari -execute safari

logs

Mar 26 12:25:56 com.apple.launchd.peruser.501[229] ([0x0-0x113113].nl.superalloy.oss.terminal-notifier[60782]): Exited with code: 1
1-61803 commented 8 years ago

This works though

$ terminal-notifier -message safari -execute "function safari { open -a safari ; } ; safari"
yaauie commented 8 years ago

This is likely because the command is invoked in a subshell of Notification Center, not a subshell of your current shell, thus it does not (and cannot) inherit user-defined functions from your current shell.

1-61803 commented 8 years ago

@yaauie, again, I corrected myself in post 2 — and provided a useful example.