Cover image for tmux

tmux

Words 505
Views
Visitors

Timeline

Timeline

2025-10-20

init

This article introduces the installation and basic configuration methods of tmux, including startup settings in a WSL environment and using tpm to manage plugins. At the same time, the article summarizes common shortcuts for session, window, and pane management, and explains how to use copy mode to view history.

tmux installation

1
2
3
4
sudo pacman -Sy tmux

# Enable
tmux

If using WSL, you can configure it to start tmux upon launch. Find the Arch Linux command line option in the settings and append it.-- tmux

tmux configuration

Install tpm

1
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

Configuration file ~/.tmux.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Set prefix key to Ctrl+q
unbind C-b
set -g prefix C-q
bind C-q send-prefix

# Mouse support (allows clicking to switch panes/windows)
set -g mouse on
# Make tmux correctly forward extended keys to Emacs.
set -g xterm-keys on
set -g default-terminal "tmux-256color"
set -g renumber-windows on
set -g base-index 1 # Set the starting index of windows to 1
set -g pane-base-index 1 # Set the starting index of panes to 1

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'


set -g @plugin 'catppuccin/tmux#v2.1.3'
set -g @catppuccin_flavor 'mocha'
# set -g @catppuccin_window_status_style "rounded"
set -g @catppuccin_window_default_text "#W"
set -g @catppuccin_window_text "#W"
set -g @catppuccin_window_current_text "#W"

# Make the status line pretty and add some modules
set -g status-right-length 100
set -g status-left-length 100
set -g status-left ""

# set -g status-right "#{E:@catppuccin_status_session}"
set -g status-right "#{E:@catppuccin_status_uptime}"

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

Then press C-q I to download the packages

Common shortcuts

Session management

Command/ShortcutDescription
tmux new -s <name>Create a new session named name
Ctrl+q dDetach the current session (session continues running in the background)
tmux lsList all sessions
tmux attach -t <name>Reconnect to a specified session
Ctrl+q $Rename the current session
Ctrl+q sSwitch session

Window Management

Command/ShortcutDescription
Ctrl+q cCreate a new window
Ctrl+q &Close the current window
Ctrl+q nSwitch to the next window
Ctrl+q pSwitch to previous window
Ctrl+q <number>Switch to window by number
Ctrl+q ,Rename current window

Pane management

Command/ShortcutDescription
Ctrl+q %Split current pane vertically
Ctrl+q "Split current pane horizontally
Ctrl+q <arrow>Move focus between panes
Ctrl+q xClose current pane
Ctrl+q zMaximize/Restore current pane
Ctrl+q SpaceSwitch pane layout

history

In tmux, the “history mode” is the copy-mode, once you enter it, you can:

  • Scroll through history with arrow keys (or C-p C-n)
  • Scroll with mouse wheel

Press:
Ctrl + q [