DEV Community

Karl Xavier
Karl Xavier

Posted on

iTerm2 with tmux -CC

iTerm2 is integrated with tmux-CC

With iTerm2, there is no need to remember tmux commands and shortcut keys, you can easily open a new window and split the screen, and restore all after disconnection.

It's super easy to use, just add the -CC parameter when using tmux in iTerm2:

For example, tmux becomes tmux -CC;
For example, tmux new-session-A-s xxx becomes tmux -CC new-session-A-s xxx.

If you configure the following in ~/.ssh/config, ssh login will automatically resume all Windows and programs last time, and the program will continue to run when accidentally disconnected:

Host xxxxx
    RequestTTY Yes
    RemoteCommand tmux -u -CC new-session -A -D -X -s yyyyy /bin/bash
# Above xxxxx and yyyyy can be replaced with any name you like
Enter fullscreen mode Exit fullscreen mode

Documentation for iTerm2: tmux Integration

This section describes common shortcut keys

The following shortcuts belong to iTerm2 and are compatible with scenarios that do not use tmux.

  • command + t New tab window
  • command + d Left and right split screen
  • command + shift + d Up and down split screen
  • command + [ or command + ] Switch between the split screen
  • command + <- or command + -> Switch tab window
  • command + shift + enter a split screen full screen, Or restore
  • command + fn + <- Scroll to the beginning of the current output
  • command + fn + -> Scroll to the end of the current output
  • command + k Clear all the current output
  • command + control + shift + d Disconnecting tmux and reconnecting restores all open Windows

Hide the tmux control window

By default, after running tmux -CC, iTerm2 will display two Windows, the original window will be shown as follows:

** tmux mode started **

Command Menu
----------------------------
esc    Detach cleanly.
  X    Force-quit tmux mode.
  L    Toggle logging.
  C    Run tmux command.
Enter fullscreen mode Exit fullscreen mode

You can hide this window by setting, iTerm2 -> Preferences... / Settings... -> General -> tmux:
Select Automatically bury the tmux client session after connecting.

New window opens

You can set the way to open the new window according to your own Preferences, iTerm2 -> Preferences... / Settings... -> General -> tmux:
When attaching, restore windows as: Choose the way you like.
After setting up, run tmux -CC and you will see the difference in each way, which will not be detailed here.

Hide the split screen title bar

By default, Windows that use tmux-CC split-screen display a single title bar, which is very ugly.
The split screen title bar can be hidden by setting, iTerm2 -> Preferences... / Settings... -> Appearance -> Panes:
Do not select Show per-pane title bar with split panes.

Inactive window style

By default, Windows that use tmux-CC split screens are gray when inactive and very ugly.
You can optimize the style of the inactive window by setting, iTerm2 -> Preferences... / Settings... -> Appearance -> Dimming:
Check Dimming affects only text, not background. That's it.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more