tmux Guide
tmux
is a terminal multiplexer that allows you to manage multiple terminal sessions within a single terminal window. It's especially useful for remote sessions, as it allows you to detach and reattach to sessions without losing your work.
tmux layout:
-session1
---window1
------pane1
------pane2
---window2
---window3
-session2
---window4
---window5
-session3
---window6
Basic Commands
Starting a New Session:
tmux
This command starts a new
tmux
session.- Detaching from a Session:
PressCtrl-b
followed byd
to detach from the current session. Listing Sessions:
tmux list-sessions
This command lists all the active
tmux
sessions.Attaching to an Existing Session:
tmux attach -t [session-name]
Replace
[session-name]
with the name of the session you want to attach to.
Window Management
Splitting the Window:
- Horizontal Split: Press
Ctrl-b
followed by%
. - Vertical Split: Press
Ctrl-b
followed by"
.
- Horizontal Split: Press
- Switching Between Panes:
PressCtrl-b
followed by the arrow key in the direction of the pane you want to switch to. - Resizing Panes:
PressCtrl-b
followed byCtrl
and an arrow key to resize the pane in the direction of the arrow. - Closing a Pane:
Exit the shell of the pane or pressCtrl-b
followed byx
and then confirm withy
. - Creating a New Window:
PressCtrl-b
followed byc
. Switching Between Windows:
- Press
Ctrl-b
followed byn
for the next window. - Press
Ctrl-b
followed byp
for the previous window.
- Press
- Renaming a Window:
PressCtrl-b
followed by,
. - Closing a Window:
Close all the panes in the window or pressCtrl-b
followed by&
and then confirm withy
.
Exiting and Customization
Exiting tmux Entirely:
Detach from the session and then use:tmux kill-session -t [session-name]
- Customizing tmux:
tmux
is highly customizable. Create a~/.tmux.conf
file in your home directory and add configurations to customize its behavior and appearance.
This is just a basic introduction to tmux
. Explore its man page (man tmux
) or various online resources for more features and capabilities.
Cheatsheet
功能 | 快捷键 |
---|---|
进入copy mode | ctl-b [ 或者ctl-b pageup, 进入后可以通过滚轮、up/down进行滚屏 |
退出copy mode | q |
显示窗口信息 | ctl-b w |
新建窗口 | ctl-b c |
跳转窗口 | ctl-b 0,1,...(窗口编号) |
横向切分pane | ctl-b % |
纵向切分pane | ctl-b " |
参考资料
Tmux Cheat Sheet
How do I scroll in tmux?
inline tmux help
tmux manual
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。