5

If I run the following command in Apple Script Editor directly,

display notification "Hello, world"

I can see a notification as expected

However if I tried to invoke it via command line:

 osascript  -e 'display notification "Hello, world"'

It turns out I am running it in a tmux session. If I just ran the command in my default shell, it works as expected.

How can I get it to work with tmux?

4
  • The osascript line works fine for me…
    – Asmus
    Commented Feb 28, 2015 at 14:14
  • Are you doing it over ssh? What version of OS X?
    – 0942v8653
    Commented Feb 28, 2015 at 17:25
  • I ran it in a tmux session. Apparently it did not work if I call it in a tmux session, but works fine in my default shell. Strange Commented Feb 28, 2015 at 20:30
  • This might be caused by the same issue complicating tmux access to the OS X pasteboard. See here for details, and check if installing reattach-to-user-namespace (brew install reattach-to-user-namespace if you are running Homebrew) helps.
    – kopischke
    Commented Mar 2, 2015 at 16:54

2 Answers 2

7

As @kopischke said, install or upgrade reattach-to-user-namespace may solve this problem.

If your reattach-to-user-namespace is old, notification works well after brew upgrade reattach-to-user-namespace.

1
  • And add the line to ~/.tmux.conf set-option -g default-command "reattach-to-user-namespace -l zsh"
    – mac
    Commented May 28, 2017 at 19:30
3

Building on @snomof's answer, you'll want to install reattach-to-user-namespace through Homebrew or MacPorts and wrap the call to osascript:

reattach-to-user-namespace osascript  -e 'display notification "Hello, world"'
1
  • And add the line to ~/.tmux.conf set-option -g default-command "reattach-to-user-namespace -l zsh"
    – mac
    Commented May 28, 2017 at 19:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .