1

I really like tmux and use it often so I set the following in my .zprofile:

[[ $TERM != "screen" ]] && exec tmux

so when I open a new window, tmux will be there for me.

However, there are some strange things that happen when tmux is running:

  • gnuplot, octave and other programs that need to launch X11 to draw graphs can't seem to do so (or it takes really long - 10 minutes or so). When X11 is already running, they don't have this problem though.
  • Some scripts I write use osascript to alert me with a notification when something happens:

    osascript -e 'display notification "some text" with title "Foo"'
    

    this works fine when tmux is not active, but fails to do anything when called from within a tmux session. (note that other osascript actions do work)

Does anyone have an idea why this might be and what might be done to fix this?

Note: I've posted a similar question about the first problem on the apple.se site some time ago but got no answer. The second problem only sprung up recently so I thought I'd try my luck here.

2

Try moving [[ $TERM != "screen" ]] && exec tmux to your .zshrc file. That way the command will only be run in interactive shells.

An interactive shell is simply any shell process that you use to type commands, and get back output from those commands. That is, a shell with which you interact.

  • Aha! This works for the gnuplot problem! But not for the display notifications problem though. Any thoughts on that? If you want, please post this answer to my similar question, since it would be totally correct there! – romeovs Aug 29 '14 at 8:02
2

Your second problem seems to be an issue with tmux and the evaluation of certain AppleScripts through osascript. There's a wrapper you can install which should fix the problem.

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"'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.