Timeline
Timeline
2025-10-20
init
This article introduces the installation and configuration methods of the terminal multiplexer tmux, including how to set up tmux to start automatically when opened under WSL, and the steps to manage plugins through tpm and load configuration files. The article summarizes in detail the common shortcut keys of tmux, covering core operations such as session management (create, detach, list, reattach, rename, switch), window management (new, close, switch, rename), and pane management (vertical/horizontal split, move focus, close, maximize, switch layout). In addition, it also explains how to use history mode (copy mode) in tmux, such as scrolling through history with arrow keys or mouse wheel.
tmux installation
1234 | sudo pacman -Sy tmux# Enabletmux |
If under WSL, you can configure tmux to start on open; find the ArchLinux command line option in settings and append-- tmux
tmux configuration
Install tpm
1 | git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm |
Configuration file ~/.tmux.conf
123456789101112131415161718192021222324252627282930313233343536 | # Set prefix key to Ctrl+qunbind C-bset -g prefix C-qbind C-q send-prefix# Mouse support (can click to switch panes/windows)set -g mouse on# Make tmux correctly forward extended keys to Emacs.set -g xterm-keys onset -g default-terminal "tmux-256color"set -g renumber-windows onset -g base-index 1 # Set the starting index of windows to 1set -g pane-base-index 1 # Set the starting index of panes to 1# List of pluginsset -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 modulesset -g status-right-length 100set -g status-left-length 100set -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 shortcut keys
Session management
| Command/Shortcut key | Description |
|---|---|
tmux new -s <name> | Create a new session named name |
Ctrl+q d | Detach the current session (the session continues running in the background) |
tmux ls | List all sessions |
tmux attach -t <name> | Reattach to the specified session |
Ctrl+q $ | Rename the current session |
Ctrl+q s | Switch session |
Window management
| Command/Shortcut key | Description |
|---|---|
Ctrl+q c | Create a new window |
Ctrl+q & | Close the current window |
Ctrl+q n | Switch to the next window |
Ctrl+q p | Switch to previous window |
Ctrl+q <number> | Switch to the window with the specified number |
Ctrl+q , | Rename the current window |
Pane management
| Command/Shortcut key | Description |
|---|---|
Ctrl+q % | Split the current pane vertically |
Ctrl+q " | Split the current pane horizontally |
Ctrl+q <arrow> | Move focus between panes |
Ctrl+q x | Close the current pane |
Ctrl+q z | Maximize/restore the current pane |
Ctrl+q Space | Switch pane layout |
history
In tmux, ‘history mode’ is copy-mode. Once you enter it, you can:
- Scroll through history with arrow keys (or C-p C-n)
- Scroll with the mouse wheel
Press:
Ctrl+q [
