2

I have ...

if [ "$TMUX" = "" ]; then tmux; fi

... in my .zshrc which works great for ssh connections.

However, I have trouble with Terminal.app.

When I type exit, tmux closes, but I am left in an open window that says [exited].

I have to type exit again to close the window.

How do I invoke tmux in Terminal.app to avoid having to type exit twice?

2 Answers 2

3

The way you're currently doing it, you need to exit again because you're running tmux as a child process of the shell.

IIRC, you need to replace the current shell process via exec instead, like so:

if [ "$TMUX" = "" ]; then exec tmux; fi

0
1

For someone stumbling upon it in the future - how I did it was as follows:

  1. Start Terminal.app
  2. Open Preferences
  3. Go to "Profile" -> "Shell"
  4. In the "Start" section select "Execute command" and enter exec tmux (make sure run in own shell is also selected)

You must log in to answer this question.

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