130

Why should I use tmux when iterm2 has split panes?

I have never used tmux, and want to know if there are advantages to using that in my workflow instead of the split pane features iterm2 has.

I really like the dimming of inactive windows that iTerm2 split panes offers. Does tmux do something similar?

What are the advantages/disadvantages of each?

pizza247
  • 3,869
  • 7
  • 33
  • 47
  • 30
    I don't see how this is off topic. I read the faq. I have to dissagree with josh, devin and robert. – pizza247 Apr 06 '12 at 14:50
  • 1
    If you agree that it should be reopened, nominate it! It's next to the edit link under the tags for the question. – pizza247 Feb 11 '13 at 20:38
  • `tmux` can be used on a variety of operating systems (including Windows) allowing you to shift systems and still feel at home. iTerm is macOS only. – Niko Bellic Nov 29 '17 at 21:33

4 Answers4

79

There is another advantage of tmux: what happens if you accidentally close iterm2? If you do it really by accident, you want to reopen everything again. With tmux it is normally as simple as reattaching session without losing anything. Most terminal emulators send SIGHUP to all children which terminates them by default and thus you lose unsaved data (at least, shell and vim command history and other data stored in viminfo) and running processes and thus reopening means rerunning everything.

ZyX
  • 52,536
  • 7
  • 114
  • 135
  • That's awesome. Definitely can't do that with iterm2 – pizza247 Apr 04 '12 at 18:34
  • 13
    If you use `tmux` for iterm2's split panes, it works exactly the same way as tmux, it just draws using iterm2's UI. – prater Feb 19 '13 at 18:29
  • 8
    FWIW, now iTerm2 can remember your opened sessions (even with the screen output). So it will reopen everything even after rebooting the computer. – Aziz Alto Dec 30 '16 at 04:52
  • This is _the_ answer that will keep me using `tmux`. I've never used iTerm2, so I can't vouch for what @AzizAlto said; and if that's true, then the `tmux` support with iTerm2 is pretty neat. But, when it comes to other terminal emulators, such as Windows Terminal--this is why _this_ answer is _the_ answer. Thanks! – fourpastmidnight Jun 27 '23 at 17:15
24

iTerm2 can use tmux for it's split panes. Personally, I'm used to tmux by itself at this point, so I've not leveraged this ability extensively - but if you are used to iTerm2 split panes, you can get the benefits of tmux (mostly screen-like session saving) with the iTerm aesthetics.

https://gitlab.com/gnachman/iterm2/wikis/TmuxIntegration

prater
  • 2,330
  • 1
  • 17
  • 15
15

My approach (not based on any particular insight) is to use iTerm tabs and panes to separate servers, and screen / tmux on the server to persist sessions.

I don't often have anything of importance running locally, but often do remotely.

kermatt
  • 1,585
  • 2
  • 16
  • 36
4

Never used iterm2, however I have played with tmux a little and there are several articles about using tmux and vim together. These articles show how you can control a tmux session via the tslime plugin, and others, from Vim. What's nice about it is that you can run a command in Vim to compile your files, run unit tests, etc. without every leaving Vim, but you see the command run in the other tmux pane.

Apologies for not being a complete answer, but hopefully it helps point you in the right direction.

LINK: https://joshuadavey.com/2012/01/10/faster-tdd-feedback-with-tmux-tslime-vim-and-turbux/

Dave Powers
  • 2,051
  • 2
  • 30
  • 34
blockcipher
  • 2,144
  • 4
  • 22
  • 35
  • My question arose this morning when listening to an episode of the changelog about tmux. That was mentioned, but I didn't realize it worked like that. definitely worth looking into. – pizza247 Apr 04 '12 at 17:07