TMUX
Created: 2025-11-30
Updated: 2025-11-30
Comprehensive TMUX notes including essential commands and configuration. Check out my dotfiles for complete development environment configs.
Useful Command
TPM
- Install Plugins:
<prefix> I - Update Plugins:
<prefix> U - Remove Plugins:
<prefix> opt u - Remove Plugins:
~/.tmux/plugins/tpm/bin/clean_plugins
Sessions
- Create New Session:
tmux/tmux new -s {newSessionName}/<prefix> :new -s {newSessionName} - Rename:
<prefix> $ - List Session:
tmux ls/<prefix> s - List Session and Windows:
<preifx> w - Switch Session:
<prefix> ): next session<prefix> (: previous session
- Attach:
tmux a/tmux a -t {SessionName} - Detach:
<prefix> d - Kill:
tmux kill-session -t {SessionName}/<prefix> :kill-session
Windows
- Create New Window:
<prefix> c - Rename:
<prefix> , - Toggle Last Active Window:
<prefix> l - Switch Windows:
<prefix> {number}<prefix> n: next window<prefix> p: previous window
- Swap Windows:
<prefix> :swap-window -s {number} -t {number} - Close Window:
<prefix> &
Panes
- Split Pane Horizontally:
<prefix> % - Split Pane Vertically:
<prefix> " - Toggle Last Active Pane:
<prefix> ; - Switch Pane:
<prefix> {arrowKeys ← → ↑ ↓ }<prefix> q+{number}
- Swap Panes:
<prefix> {and<prefix> } - FullScreen a Pane:
<prefix> z - Resize Pane:
<prefix> <C-{hjkl}>as vim - Turn Pane to Window:
<prefix> ! - Close Pane:
<prefix> x - Merge W1 as Panes in W0:
<prefix> :join-pane -s 1 -t 0 - Move Pane from W0P1 to W1P2:
<prefix> :join-pane -s 0.0 -t 1.2
Install
Bash
brew install tmux
TPM := TMUX Plugin Manager
Installation
Bash
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
mkdir ~/.config/tmux
touch ~/.config/tmux/tmux.conf
vim ~/.config/tmux/tmux.conf
- edit
~/.config/tmux/tmux.confBash# List of plugins set -g @plugin 'tmux-plugins/tpm' set -g @plugin 'tmux-plugins/tmux-sensible' # Other examples: # set -g @plugin 'github_username/plugin_name' # set -g @plugin 'github_username/plugin_name#branch' # set -g @plugin 'git@github.com:user/plugin' # set -g @plugin 'git@bitbucket.com:user/plugin' # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) run '~/.tmux/plugins/tpm/tpm'
My TMUX config
Bash
# NOTE: Use <leader><S-I> to install plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'tmux-plugins/tmux-resurrect' # persist tmux sessions after computer restart
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-restore 'on'
# set -g @continuum-save-interval '15' # automatically saves sessions for you every 15 minutes
### use prefix + Ctrl-s to save manually
### use prefix + Ctrl-r to restore manually
set-option -g default-terminal "tmux-256color"
set-option -ga terminal-overrides ",*:RGB"
set-option -g default-shell "/bin/zsh"
set-option -g default-command "${SHELL} -li"
set-option -g status-position top
set-option -g mouse on
set-option -g set-clipboard on
set-option -g focus-events on
set-option -s escape-time 0
# Set prefix to Ctrl-Space
set-option -g prefix C-Space
unbind-key C-b
bind-key C-Space send-prefix
# Make index start from 1
set -g base-index 1
setw -g pane-base-index 1
# Refresh tmux setting
unbind-key r
bind-key r source-file ~/.tmux.conf
set-window-option -g mode-keys vi
bind-key -T copy-mode-vi 'v' send -X begin-selection # start selecting text with "v"
bind-key -T copy-mode-vi 'y' send -X copy-selection # copy text with "y"
unbind-key -T copy-mode-vi MouseDragEnd1Pane # don't exit copy mode when dragging with mouse
#
# Keymaps
#
# Create new panes and windows with current path, Split window
bind c new-window -c "#{pane_current_path}"
unbind-key %
bind-key | split-window -h -c "#{pane_current_path}"
unbind-key '"'
bind-key - split-window -c "#{pane_current_path}"
# window movement
bind-key < swap-window -t -1
bind-key > swap-window -t +1
# Adjust pane size
unbind-key j
unbind-key k
unbind-key h
unbind-key l
bind-key -r J resize-pane -D 1
bind-key -r K resize-pane -U 1
bind-key -r H resize-pane -L 2
bind-key -r L resize-pane -R 2
bind-key -r m resize-pane -Z
bind-key h previous-window
bind-key l next-window
bind-key j last-window
# use "<leader>u" to toggle pane below
bind-key u run-shell "pane_count=\$(tmux list-panes | wc -l | tr -d ' '); \
if [ \"\$pane_count\" -eq 1 ]; then \
tmux split-window -c \"#{pane_current_path}\" -l 10; \
elif [ \"\$(tmux display-message -p '#{window_zoomed_flag}')\" = \"1\" ]; then \
tmux resize-pane -Z; \
tmux select-pane -D; \
else \
tmux select-pane -U; \
tmux resize-pane -Z; \
fi"
#
# Themes
#
set -g @plugin 'o0th/tmux-nova'
set -g @nova-nerdfonts true
set -g @nova-nerdfonts-left
set -g @nova-nerdfonts-right
set -g @nova-pane-active-border-style "#78a2c1"
set -g @nova-pane-border-style "#4c566a"
set -g @nova-status-style-bg "#4c566a"
set -g @nova-status-style-fg "#d8dee9"
set -g @nova-status-style-active-bg "#89c0d0"
set -g @nova-status-style-active-fg "#2e3540"
set -g @nova-status-style-double-bg "#2d3540"
set -g @nova-pane "#I.#W"
set -g @nova-segment-mode " #S"
set -g @nova-segment-mode-colors "#{?client_prefix,#ffd182,#78a2c1} #2e3440"
if-shell "[ $(uname) = 'Darwin' ]" \
"set -g @nova-segment-custom ' '" \
"set -g @nova-segment-custom ' '"
set -g @nova-segment-custom-colors "#89c0d0 #2e3440"
if-shell "[ $(uname) = 'Darwin' ]" \
"set -g @nova-segment-whoami '#{#{=/-32/…:#{s|/Users/$USER|~|:#{pane_current_path}}}}'" \
"set -g @nova-segment-whoami '#{#{=/-32/…:#{s|/home/$USER|~|:#{pane_current_path}}}}'"
set -g @nova-segment-whoami-colors "#78a2c1 #2e3440"
set -g @nova-rows 0
set -g @nova-segments-0-left "mode"
set -g @nova-segments-0-right "custom whoami"
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'