Lesson learnt: use iTerm2 and tmux

Nitesh Turaga
2 min readJul 1, 2019

--

Github: nturaga, twitter: niteshturaga

A terminal multiplexer would be a great way to work(in theory), but learning and re-learning the shortcuts for tmux seems to be too much work, unless I was using it on a daily basis.

iTerm2’s tmux integration solves these problems for me. Especially when i’m writing code in front of people and fumbling with my iTerm2 window.

Tmux integration

When you run tmux -CC, a new tmux session is created and an iTerm2 window opens. It acts like a normal iTerm2 window. The difference is that when iTerm2 quits or the ssh session is lost, tmux keeps running. You can return to the host you were logged into and run tmux -CC attach and the iTerm2 windows will reopen in the same state they were in before.

Usage

I was able to just learn 2 new commands and be on my way,

  1. I open an iTerm2 window and run this command,
/home/❯❯❯ tmux -CC
** tmux mode started **
Command Menu
----------------------------
esc Detach cleanly.
X Force-quit tmux mode.
L Toggle logging.
C Run tmux command.2. Re-attach the window after losing it.

2. While closing a window you get to kill or hide the tmux integrated iTerm2 session. I usually go with hide .

3. After using the new window and closing it, if I want to re-attach it,

/home/❯❯❯ tmux -CC attach

Use Cases

For users who do most of their work in ssh:

  • I accidentally press a wrong key and close the window without saving my work.
  • Restore the environment you had at work when you get home.
  • No more anxiety about letting System Update reboot.

Advantages:

  • I don’t need to know how tmux shortcuts work, and don’t need to memorize a new system.

TL; DR : Get ITerm2, and use the inbuilt tmux integration .

--

--

No responses yet