tmux日常使用
文章目录
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
---window6Basic Commands
Starting a New Session:
tmuxThis command starts a new
tmuxsession.- Detaching from a Session:
PressCtrl-bfollowed bydto detach from the current session. Listing Sessions:
tmux list-sessionsThis command lists all the active
tmuxsessions.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-bfollowed by%. - Vertical Split: Press
Ctrl-bfollowed by".
- Horizontal Split: Press
- Switching Between Panes:
PressCtrl-bfollowed by the arrow key in the direction of the pane you want to switch to. - Resizing Panes:
PressCtrl-bfollowed byCtrland an arrow key to resize the pane in the direction of the arrow. - Closing a Pane:
Exit the shell of the pane or pressCtrl-bfollowed byxand then confirm withy. - Creating a New Window:
PressCtrl-bfollowed byc. Switching Between Windows:
- Press
Ctrl-bfollowed bynfor the next window. - Press
Ctrl-bfollowed bypfor the previous window.
- Press
- Renaming a Window:
PressCtrl-bfollowed by,. - Closing a Window:
Close all the panes in the window or pressCtrl-bfollowed 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:
tmuxis highly customizable. Create a~/.tmux.conffile 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
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论