Tmux
Contents
Basic
Creating Named Sessions
| |
or
| |
Detaching Sessions
CTRL-b, then d
Reattaching to Existing Sessions
| |
or
| |
- If there is only session, then
tmux attach.- If there are multiple sessions, then
tmux attach -t second_session. BTY, you can also use this when you only have one session.
Killing Sessions
- In sesssion, use
exit. - Kill specific session when not in session,
| |
BTY, if there is no sessions, after typing tmux ls, you will get
| |
Creating and Naming Windows
In terminal
-n: the name of new window.1tmux new -s windows -n shellIn session
PREFIX cPREFIX ,will rename the new window.
Moving Between Windows
next and previous window
PREFIX nandPREFIX pdefault id of window
PREFIX 0toPREFIX 9find a window
PREFIX fwindow list
PREFIX w
Close a Window
- type
exitafter command finish executed. PREFIX &
If you want to quit a tmux session, you’ll have to close all windows.
Panes
- vertically:
PREFIX % - horizontally:
PREFIX " - switch between them:
- cycle through:
PREFIX o PREFIX UP,PREFIX DOWN,PREFIX LEFT, orPREFIX RIGHT
- cycle through:
Pane Layouts
types:
- even-horizontal
- even-vertical
- main-horizontal
- main-vertical
- tiled
cycle through these types by pressing PREFIX SPACEBAR.
Closing Panes
exitPREFIX X. If there is only one pane in current window, it will close this window at the same time.
Command Mode
press PREFIX : to enter command mode.
- create new window with a name,
| |
- create new window with a name and a command,
| |
top will execute immediately after new window created. What’s really cool is that this window close instantly when you press q to close top.
Quick Reference
创建会话
| 命令 | 描述 |
|---|---|
tmux new-session | 创建一个未命名的会话。可以简写为 tmux new 或者就一个简单的 tmux |
tmux new -s development | 创建一个名为“development”的会话 |
tmux new -s development -n editor | 创建一个名为“development”的会话并把该会话的第一个窗口命名为“editor” |
tmux attach -t development | 连接到一个名为“development”的会话 |
会话、窗口和面板的默认快捷键
| 快捷键 | 功能 |
|---|---|
PREFIX d | 从一个会话中分离,让该会话在后台运行。 |
PREFIX : | 进入命令模式 |
PREFIX c | 在当前tmux会话创建一个新的窗口,是 new-window 命令的简写 |
PREFIX 0...9 | 根据窗口的编号选择窗口 |
PREFIX w | 显示当前会话中所有窗口的可选择列表 |
PREFIX , | 显示一个提示符来重命名一个窗口 |
PREFIX & | 关闭当前窗口,带有确认提示 |
PREFIX % | 把当前窗口垂直地一分为二,分割后的两个面板各占50%大小 |
PREFIX " | 把当前窗口水平地一分为二,分割后的两个面板各占50%大小 |
PREFIX o | 在已打开的面板之间循环移动当前焦点 |
PREFIX q | 短暂地显示每个面板的编号 |
PREFIX x | 关闭当前面板,带有确认提示 |
PREFIX SPACE | 循环地使用tmux的几个默认面板布局 |
References
- [tmux-Productive-Mouse-Free-Development_zh(https://github.com/aqua7regia/tmux-Productive-Mouse-Free-Development_zh)