8

I currently switched to iTerm2 + VIM for my dev environment. I noticed that the last version of iTerm2 supports tmux and there were people using tmux to split the window into several sessions. I also noticed that iTerm2 has options out of the box to split the window into several sessions. You can split as many sessions as you want vertically and horizontally by just using CMD+D for example. So to me it seems that you can accomplish the same functionality with those options. I could be totally wrong.

My questions is: Is there a difference/benefit by using tmux over the splitting options on iTerm2?

3 Answers 3

10

if you close iterm2 then the shells attached to that instance of iterm2 are destroyed / closed as well. process-hierchy of this situation:

iterm2
  +---- shell
  +---- shell
  +---- shell

if you close the iterm2 which holds tmux, then tmux and the shells inside that tmux instance keep running. you can later reattach to that tmux instance (thats essentially how folks work on remote-servers in case the connection drops) and get back the situation as it was before you closed the iterm2. process-hierarchy of this situation:

iterm2
  +---- tmux
          +---- shell
          +---- shell
          +---- shell

to quote from tmux directly:

tmux is a terminal multiplexer: it enables a number of terminals (or windows), each running a separate program, to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.

an older project providing basically the same functionality is screen

4
  • Thanks akira! that was my very first question on SU and received a great answer, just exactly what I needed!
    – wonitta
    Mar 9, 2012 at 7:29
  • Isn't the process hierarchy more like: iterm2 > shell > tmux client and tmux server > shell? So when you close iTerm, you close the tmux client but the server is still around.
    – Henrik N
    Mar 18, 2012 at 21:11
  • @HenrikN: iTerm2 might call the tmux-client "directly". you would get the same effect if you launch "exec tmux attach" or something similar. and yes, tmux consists of 2 parts. but that distinction does not improve the understanding why iterm2-splitting is different from tmux-splitting, does it?
    – akira
    Mar 19, 2012 at 7:31
  • @akira I just wanted to clear it up because you put tmux under iTerm, which perhaps makes it harder to see how tmux survives when the iTerm process exits. To me, the best way to understand that is to realize that the tmux server is independent of iTerm (but the client is not). But certainly, the fact that tmux and not iterm owns the split shells is a key point.
    – Henrik N
    Mar 19, 2012 at 8:14
2

Accepted answer is great and is my favorite thing about tmux, but often overlooked is multiple clients can be attached to each tmux session. So, one or more users can connect to a tmux session from different computers and they share the same information on the window.

1

There is also now a tool called iTermocil that brings the functionality of laying out windows and panes, and running pre-configured commands natively to iTerm.

Disclaimer: I am the author this tool (for the exact functionality described in the question).

1

You must log in to answer this question.

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