Tmux Personal Setup to Boost Terminal Productivity
0. Why Use Tmux?
It's easiest to understand if you compare the terminal to a 'Web Browser'.
Multitasking (Tabs and Windows) Just as you open multiple tabs in a browser to search, watch YouTube, and check email simultaneously, Tmux allows you to run a server, edit code, and check logs at the same time within a single terminal window.
Session Persistence (Safety Net)
This is its most powerful feature. If you are working on a remote server and the internet disconnects or you accidentally close the terminal, the Tmux session stays alive in the background. When you reconnect (attach), it restores exactly as you left it.
Terminology
-
Session
- Equivalent to the entire browser window.
- Just as you might keep
Project AandProject Bwindows separate, it is the largest container that holds the entire context of your work.
-
Window
- Equivalent to a 'Tab' in a browser.
- A space within a single session where you switch screens for different purposes, like Server (1) and DB (2).
-
Pane
- A screen split top/bottom or left/right within a single tab.
- A divided area in one window where you can see an editor on the left and logs on the right simultaneously.
1. Installation & Essential Plugins
Based on Mac (Homebrew) environment. You must install TPM (Tmux Plugin Manager) after the basic installation to utilize 100% of its powerful features.
1. Install Tmux
brew install tmux2. Install Plugin Manager (TPM)
Essential for easily managing various plugins.
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm2. Practical Optimization Settings
(.tmux.conf)
I changed the default Tmux settings (the prefix key C+b is too far and uncomfortable) to fit a practical workflow.
Create the file vi ~/.tmux.conf and paste the contents below exactly.
# ==========================================
# 1. Basic Convenience Settings
# ==========================================
# Change Prefix Key (Default Ctrl+b twists your hand -> Change to Ctrl+a)
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# Enable Mouse (Resize panes, scroll, etc.)
set -g mouse on
# Index Settings (Keyboard 0 is too far, start from 1)
set -g base-index 1
set -g pane-base-index 1
set -g renumber-windows on # Auto renumber windows when closed
# ==========================================
# 2. Key Bindings
# ==========================================
# Intuitive Split (Split maintaining current path)
# | : Split Horizontally
# - : Split Vertically
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# Vim Style Copy Mode (v:select, y:copy)
set-window-option -g mode-keys vi
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
# ==========================================
# 3. Plugins
# ==========================================
# Integrate navigation between Vim and Tmux (Ctrl+hjkl)
set -g @plugin 'christoomey/vim-tmux-navigator'
# Load Essential Plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# Run TPM (Must be at the very bottom of the file)
run '~/.tmux/plugins/tpm/tpm'-
Plugin Manager (TPM)
- It acts like the App Store for your smartphone. It is a core tool that allows you to instantly install and update necessary plugins with a single shortcut (
Ctrl + a + I) without complex manual configuration.
- It acts like the App Store for your smartphone. It is a core tool that allows you to instantly install and update necessary plugins with a single shortcut (
-
Essential Optimization (Sensible)
- It resolves the frustrating key input delay (Esc) and screen rendering speed issues of the default state.
How to Apply Settings:
- Save the file above.
- Type
tmux source ~/.tmux.confin the terminal.- After starting Tmux, press
Ctrl + athenI(Capital i) to install plugins.
3. Smart Execution Function
t
Typing tmux new -s ... every time is cumbersome. Add this short command to your shell configuration file (~/.zshrc, etc.) to "create if missing, connect if exists".
Bash
# t [name] : Connect if session exists, create if not
function t() {
if [ -z "$1" ]; then
# Connect to 'main' session if 't' is typed without a name
tmux new -A -s main
else
# Connect to corresponding session if 't project_name' is typed
tmux new -A -s "$1"
fi
}- Usage: Want to create a "Hello" session? -> Just type
t Helloin the terminal.
4. Key Shortcuts Cheatsheet
All commands are entered after pressing the Prefix (Ctrl + a).
| Category | Shortcut (After Ctrl + a) | Description |
|---|---|---|
| Session | s |
View/Switch/Delete(x) Sessions (Most Important) |
d |
Detach Session (Keep running in background) | |
$ |
Rename Current Session | |
| Window | c |
Create New Window (Tab) |
, |
Rename Window | |
n / p |
Move to Next / Previous Window | |
| Pane | ` |
Backtick |
- |
Split Screen Vertically | |
z |
Zoom Current Pane (Toggle Fullscreen) | |
| Move | Ctrl + h,j,k,l |
Move Between Panes (Move immediately without Prefix) |
5. Troubleshooting: When Right Move (Ctrl+l) Doesn't Work
Tip Important for keyboard-centric environments that don't use a mouse.
Even with perfect settings, you might encounter a phenomenon where "Left (Ctrl+h) works but Right (Ctrl+l) doesn't move".
Cause: Terminal Conflict
In Unix systems, Ctrl + l is the "Clear Screen" command. This happens because the Terminal App (iTerm2, Alacritty, etc.) intercepts this key before Tmux or Vim receives the signal.
Diagnosis (cat Test)
Perform the following in the terminal to catch the culprit.
- Type
catin any shell and press Enter (Input wait state). - Press
Ctrl + l.- If
^Lappears on screen? β Normal (Not a terminal issue).- If
^Lappears when pressingCtrl + l, it means the shell recognized the key input as a 'literal'.
- If
- If the screen clears? β Culprit Found (Terminal intercepted the key).
- If
Solution
You need to unbind the Ctrl + l mapping in the terminal settings.
-
iTerm2:
Settings>Profiles>Keys>Key Mappings-> Delete^litem. -
Alacritty/Zsh: Add the code below to your shell configuration (
~/.zshrc) to unbind the key.
Unbind Ctrl+l (Yield to Vim/Tmux)
bindkey -r "^L"Log
- β’ 2026-01-23: fleeting