Introduction
This article provides an overview of using Tmux with iTerm2, a popular terminal emulator for macOS. Tmux is a terminal multiplexer that allows you to manage multiple terminal sessions from a single window.
Prerequisites
Before getting started, ensure that you have the following:
- iTerm2: A terminal emulator for macOS (https://iterm2.com/)
- Tmux: A terminal multiplexer (usually installed by default on macOS)
Installing tmux-CC (iTerm2 Tmux Integration)
Tmux integration with iTerm2 is provided by the tmux-CC plugin. To install it, follow these steps:
- Open iTerm2 preferences.
- Navigate to the "Profiles" tab.
- Select the profile you want to modify (or create a new one).
- Go to the "Advanced" tab.
- In the "Startup" section, check the box next to "Run shell script" and paste the following command:
- Click "Add" and then "OK" to save the changes.
# Install tmux-CC
brew install https://raw.githubusercontent.com/tmux-plugins/tpm/master/scripts/install_tpm.sh
tpm install tmux-cc
Configuring tmux-CC
After installing tmux-CC, you can customize its behavior by editing the configuration file:
# Open the tmux-cc configuration file
nano ~/.tmux.conf
For more information about available options, refer to the tmux-cc GitHub repository.
Using Tmux with iTerm2
Now that you have tmux-CC installed and configured, you can start using Tmux with iTerm2:
- Launch a new Tmux session:
- Detach from the Tmux session:
- Attach to an existing Tmux session:
tmux new-session
Ctrl-b d
tmux attach
Scrolling within Tmux sessions
By default, scrolling within Tmux sessions is not supported in iTerm2. To enable scrolling, follow these steps:
- Open iTerm2 preferences.
- Navigate to the "Profiles" tab.
- Select the profile you want to modify (or create a new one).
- Go to the "Advanced" tab.
- In the "Scrolling" section, select "Scrollback buffer" from the "Scrolling behavior" dropdown.
Resources
- Tmux: https://github.com/tmux/tmux/wiki
- Tmux Plugin Manager: https://github.com/tmux-plugins/tpm
- tmux-cc: https://github.com/tmux-plugins/tmux-cc