tmux 速查表
可搜索、可打印的 tmux 参考——会话、窗口、窗格、复制模式、prefix 重绑定、配置、插件和脚本。免费。
Sessions
11tmux new -s work
Start a named session
tmux new -s work -d
Start detached (in the background)
tmux new -As work
Attach if it exists, else create
tmux ls
List running sessions
tmux attach -t work
Attach to a session (a = attach)
Prefix d
Detach from the current session
Prefix $
Rename the current session
Prefix s
Interactive session switcher
Prefix ( / )
Previous / next session
tmux kill-session -t work
Kill one session
tmux kill-server
Kill all sessions and the server
Windows
10Prefix c
Create a new window
Prefix ,
Rename the current window
Prefix n / p
Next / previous window
Prefix 0..9
Jump to window by number
Prefix l
Toggle to the last-used window
Prefix w
Interactive window list
Prefix f
Find a window by name
Prefix &
Kill the current window (confirms)
Prefix .
Move window to another index
swap-window -s 2 -t 0
Swap two windows by index
Panes
12Prefix %
Split vertically (side by side)
Prefix "
Split horizontally (stacked)
Prefix arrow keys
Move between panes
Prefix o / ;
Next pane / last-active pane
Prefix q
Show pane numbers (press to jump)
Prefix z
Zoom: toggle pane full-screen
Prefix x
Kill the current pane (confirms)
Prefix { / }
Swap pane with previous / next
Prefix Ctrl+arrow
Resize pane one cell at a time
Prefix Space
Cycle built-in pane layouts
Prefix !
Break the pane into its own window
join-pane -s 2 -t 1
Move a pane into another window
Copy mode & scrolling
11Prefix [
Enter copy mode (scroll history)
q / Escape
Leave copy mode
Prefix PgUp
Enter copy mode scrolled one page up
Space then Enter
Start selection, then copy (emacs)
v then y
Start selection, then copy (vi keys)
Prefix ]
Paste the copied text
/ and ?
Search forward / backward
n / N
Next / previous search match
g / G
Top / bottom of history (vi keys)
setw -g mode-keys vi
Use vi keys in copy mode
tmux capture-pane -p > out.txt
Dump pane contents to a file
Prefix key & rebinding
9Ctrl+b
The default prefix key
Prefix key, then the command key
Press separately, not together
set -g prefix C-a
Use Ctrl+a as prefix (screen style)
unbind C-b
Free the old prefix binding
bind C-a send-prefix
Prefix twice sends it to the app
bind r source-file ~/.tmux.conf
Reload config with Prefix r
bind -n M-Left select-pane -L
-n = no prefix needed (Alt+Left)
bind -r H resize-pane -L 5
-r = key repeats within timeout
tmux list-keys
Show all current key bindings
Command mode (:)
9Prefix :
Open the tmux command prompt
:new-window -n logs
New window named "logs"
:split-window -h
Split the pane horizontally
:rename-session dev
Rename the current session
:setw synchronize-panes on
Type into all panes at once
:swap-pane -s 0 -t 1
Swap two panes by index
:resize-pane -D 10
Resize down by 10 cells
:source-file ~/.tmux.conf
Reload the configuration
:kill-server
Stop tmux entirely
Configuration essentials
11set -g mouse on
Mouse: select panes, resize, scroll
set -g base-index 1
Number windows from 1, not 0
setw -g pane-base-index 1
Number panes from 1 too
set -g renumber-windows on
Re-number after closing a window
setw -g mode-keys vi
vi keys in copy mode
set -g history-limit 50000
Bigger scrollback buffer
set -g default-terminal "tmux-256color"
Proper colors inside tmux
set -sg escape-time 0
No Esc delay (helps vim users)
bind | split-window -h
Memorable split: | = vertical
bind - split-window -v
Memorable split: - = horizontal
set -g focus-events on
Pass focus events to programs
Plugins & TPM
10git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
Install the plugin manager
set -g @plugin 'tmux-plugins/tpm'
Declare TPM in .tmux.conf
run '~/.tmux/plugins/tpm/tpm'
MUST be the last config line
Prefix I
Install newly declared plugins
Prefix U
Update installed plugins
Prefix Alt+u
Remove undeclared plugins
@plugin 'tmux-plugins/tmux-resurrect'
Save/restore sessions across reboots
@plugin 'tmux-plugins/tmux-continuum'
Auto-save sessions periodically
@plugin 'tmux-plugins/tmux-yank'
Copy to the system clipboard
@plugin 'tmux-plugins/tmux-sensible'
Sane defaults everyone agrees on
Sharing & pairing
8tmux -S /tmp/pair new -s pair
Session on a shared socket file
chmod 777 /tmp/pair
Let the partner access the socket
tmux -S /tmp/pair attach
Partner attaches to the socket
tmux attach -t work -r
Attach read-only (view, no typing)
Two clients, one session
Both mirror the same window
tmux new -s me -t work
Grouped session: independent windows
ssh user@host -t tmux new -As dev
SSH straight into a tmux session
setw -g aggressive-resize on
Size to the active client, not min
Scripting from the shell
10tmux new -d -s job 'npm run build'
Run a command in a detached session
tmux send-keys -t job 'ls -la' Enter
Type into a session remotely
tmux send-keys -t job C-c
Send Ctrl+C to stop a process
tmux has-session -t job 2>/dev/null && echo up
Check if a session exists
tmux capture-pane -t job -p
Print a pane's output to stdout
tmux split-window -t job -h 'htop'
Split and run a command in it
tmux select-window -t job:2
Target session:window from scripts
tmux display-message -p '#S'
Print the current session name
tmux list-panes -a
List every pane on the server
tmux wait-for done
Block until a signal is fired
Status bar
10set -g status off
Hide the status bar entirely
set -g status-position top
Move the bar to the top
set -g status-style bg=black,fg=white
Bar colors
set -g status-left '[#S] '
Show the session name on the left
set -g status-right '%H:%M %d-%b'
Clock and date on the right
set -g status-interval 5
Refresh the bar every 5 seconds
setw -g window-status-current-style fg=green
Highlight the active window
#S #I #W #P #H
Session, window idx/name, pane, host
#(uptime | cut -d, -f1)
Embed shell output in the bar
set -g status-justify centre
Center the window list
Troubleshooting
10tmux -V
Show the tmux version
tmux info
Dump server, client and terminal info
tmux show-options -g
List all global option values
Config changes not applied
.tmux.conf loads at server start only
Prefix : source-file ~/.tmux.conf
Reload config without restarting
"sessions should be nested with care"
You ran tmux inside tmux ($TMUX set)
TERM=xterm-256color tmux
Fix wrong/missing colors outside
Esc feels laggy in vim
Set escape-time 0 (see config)
tmux kill-server
Last resort: full clean restart
Sessions gone after reboot
Server is not persistent; use resurrect
没有条目匹配“:q”。
关于 tmux 速查表
这份 tmux 速查表将键绑定和命令汇集在一个可搜索的页面上:会话、窗口、窗格、复制模式和滚动、前缀键及其重绑定、命令模式、配置要点、插件和 TPM、共享和配对、Shell 脚本、状态栏,以及故障排查。
tmux 几乎完全依赖一个前缀键形成的肌肉记忆,因此速查表将每个绑定显示为前缀加键的形式,旁边是对应的 Shell 命令(如有)——当你在编写会话脚本而非手动操作时很方便。
与本系列的其他速查表一样,它免费且在客户端运行:使用搜索框实时过滤行,通过固定目录在章节间跳转,点击即可复制任何命令,还可以打印页面作为终端旁的参考。
如何使用 tmux 速查表
- 打开速查表,浏览各章节,从“会话”和“窗口”到“故障排查”。
- 搜索关键词如 split、detach 或 copy 以实时过滤每一行。
- 需要更改前缀键或窗格绑定时跳转到“配置要点”。
- 点击命令或其复制图标,直接复制到终端或 .tmux.conf 中。
- 使用打印功能获取完整 tmux 参考的纸质版。
常见问题
十二个章节:会话、窗口、窗格、复制模式和滚动、前缀键及其重绑定、命令模式、配置要点、插件和 TPM、共享和配对、Shell 脚本、状态栏,以及故障排查。
Ctrl-b。前缀章节展示了相对于它的每个绑定,并给出了将其重绑定为 Ctrl-a 的 .tmux.conf 配置行(如果你偏好的话)。
复制模式章节涵盖了进入复制模式、在其中移动和搜索、开始和结束选择以及粘贴缓冲区——支持 emacs 和 vi 按键模式。
可以。点击任意行或其复制图标,命令即可立即复制。
是的,完全免费,在浏览器中运行,无需登录。
热门搜索
tmux 速查表
tmux 命令
tmux 快捷键
tmux 拆分窗格
tmux 复制模式
tmux 配置示例
tmux 会话命令
需要帮助?
使用此工具时遇到问题?请告诉我们的团队。