当前位置:网站首页>tmux concept and usage
tmux concept and usage
2022-08-04 06:29:00 【KuoGavin】
什么是tmux?Github的地址:https://github.com/tmux/tmux
可见tmux是一个终端多路复用器,Able to create in single screen condition,Access and control multiple terminal windows.At the same time, it can continue to run in the background of the host after the terminal window is disconnected,You can also reconnect later.That is, the advantages are as follows:
- split your terminal into panes which can be moved, resized, and switched between
- keep programs running after you disconnect (e.g. when working on a remote server via ssh)
tmux 安装
- Ubuntu:
sudo apt-get install tmux - RedHat / CentOS:
sudo yum install tmux
tmux 命令
在 tmux 中,有session(会话)、window(窗口)和 pane(窗格)三个概念:
- Sessions:Defines the overall task currently being done.If you are testing something,All operations and activities related to testing the thing are limited to the current session;
- Windows:Refers to a specific activity or project within a session;
- Panes:Helps programmers create multiple view panes in one window.比如,Runs in a pane,Track the error log in another pane;
structurally,就是一个 tmux 可以包含多个 session,一个 session 可以包含多个 window, 一个 window 可以包含多个 pane.
Here's a more comprehensive one tmux command manual,and is online,Paste the URL:https://phoenixnap.com/kb/tmux-tutorial-install-commands
tmux 的控制方式是——按过CTRL+b(Default prefix key)之后,Press the corresponding hotkey again.(CTRL+bThe keys are a bit awkward,That is, the two buttons are far apart,可以修改~/.tmux.confThe content of the file is modified with the prefix,并在tmux当中执行tmux source-file ~/.tmux.conf生效,The specific operation will be described below,同时AcWing中,yxcChange it to CTRL+a,Also commonly used modified prefix combinations).
Talk about prefix combinations+After the control method of the hotkey,常用的操作命令如下:
|session相关|
The approximate content is :新建 session -> 离开 session -> 查看 session 列表 -> 进入 session -> 关闭 session -> 不同 session 之间的切换 -> 重命名 session .
| 操作方式 | 用法 |
|---|---|
tmux | 新建一个session,其中包含一个window,window包含一个pane,paneopened inshell |
tmux new -s session_name | Create a new one with the specified namesession_name的会话,其余同上 |
tmux detachCTRL+b手指松开,d | 离开session,Exit from the current session,Meanwhile tasks for the current session are still running in the background |
tmux ls | 查看 session 列表,List all activesession |
tmux a / tmux attachtmux a -t session_name | 打开之前挂起的session,即Enter the most recently used session that is still in progress 打开/Enters a pending session of the specified name |
tmux kill-session -t session_name | 关闭名为session_name的session |
CTRL+b手指松开,s | 同tmux ls,View all operationssession;还可选择其它session/window/pane,会有一个GUIinterface for selection: →:展开当前项 session/window←:闭合当前项 session/window↑:选择上一项 session/window/pane↓:选择下一项 session/window/pane |
tmux switch -t session_name | 切换session |
tmux rename-session -t old_session_name new_session_nameCTRL+bPress and release,$ | 重命名当前session名 |
|window相关|
| 操作方式 | 用法 |
|---|---|
tmux new-window -n window_nameCTRL+b手指松开,c | 新创建一个window,在当前session中创建一个新的window |
tmux select-window -t window_nameCTRL+b手指松开,w | 选择指定window_namename of the window 选择其它window,会有一个GUIinterface for selection: →:展开当前项 window←:闭合当前项 window↑:选择上一项 window/pane↓:选择下一项 window/pane |
tmux rename-window new_window_nameCTRL+b手指松开,, | 操作之后,The bottom status bar turns yellow,删除原window名,Change the new onewindow名 |
tmux kill-window -t window_nameCTRL+b手指松开,& | 关闭当前窗口/(再按y进行确认) |
CTRL+b手指松开,PgUp鼠标滚轮 | 翻阅当前pane内的内容 |
|pane相关|
在使用vimeditor is used during the process tmux The pane is a very lighthearted thing.
| 操作方式 | 用法 |
|---|---|
tmux split-window -hCTRL+b手指松开,% | 将当前paneDivide left and right |
tmux split-windowCTRL+b手指松开," | 将当前paneHalf up and down |
CTRL+dCTRL+b手指松开,x输入exit+ Enter | 关闭当前pane,若当前window的所有pane关闭,则自动关闭window,session的window同理,类似shared_ptr的回收 |
tmux select-pane -U/D/L/RCTRL+b 手指松开,<方向键>`鼠标点击pane | U(Upward)/D(Downward)/L(Left)/R(Right) 选择相邻的pane 选择任意的pane |
CTRL+b的同时按<方向键>鼠标拖动pane之间分割线 | 调整pane之间分割线的位置 |
CTRL+b手指松开,z | 将当前pane全屏/取消全屏 |
CTRL+b手指松开,t | Displays the clock in the current pane,点击Enter复原 |
在 tmux When text is selected,需要按住 Shift 键.(仅支持Windows和Linux,不支持MacOS);
在 tmux 中复制/粘贴文本的通用方式:
- ① 按下
CTRL+b后松开手指,然后按[; - ② 用鼠标选中文本,The selected text is automatically copied to tmux 的剪贴板;
- ③ 按下
CTRL+b后松开手指,然后按],会将剪贴板中的内容粘贴到光标处;
tmux 配置
通过编辑~/.tmux.conf文件对 tmux 进行个性化配置,This is a separate configuration for the current user,If you want to configure all users of the host,则在根目录下创建/etc/tmux.conf文件.
Change the prefix combination,以CTRL+b改为CTRL+a为例:
unbind C-b
set -g prefix C-a
更改后保存即可.
Change shortcut keys for dividing windows,将左右,The upper and lower divisions were changed toCTRL+b,h和CTRL+b,v
unbind %
bind h split-window -h
unbind '"'
bind v split-window -v
Give a recommended configuration,It's a bit gimmicky but practical:https://github.com/gpakosz/.tmux
边栏推荐
- tensorRT教程——tensor RT OP理解(实现自定义层,搭建网络)
- LeetCode_22_Apr_2nd_Week
- MNIST handwritten digit recognition, sorted by from two to ten
- LeetCode_Nov_5th_Week
- 迅雷关闭自动更新
- Comparison of oracle's number and postgresql's numeric
- How to grow into a senior engineer?
- 【论文阅读】Mining Cross-Image Semantics for Weakly Supervised Semantic Segmentation
- Endnote编辑参考文献
- LeetCode_22_Apr_4th_Week
猜你喜欢
随机推荐
Postgresql snapshot
深度确定性策略梯度(DDPG)
How to grow into a senior engineer?
迅雷关闭自动更新
计算某像素点法线
Deep Learning Theory - Initialization, Parameter Adjustment
[日常办公][ssh]cheatsheet
CAS无锁队列的实现
双向LSTM
强化学习中,Q-Learning与Sarsa的差别有多大?
中国联通、欧莱雅和钉钉都在争相打造的秘密武器?虚拟IP未来还有怎样的可能
度量学习(Metric learning、损失函数、triplet、三元组损失、fastreid)
Introduction to Convolutional Neural Networks
【论文阅读】Mining Cross-Image Semantics for Weakly Supervised Semantic Segmentation
投稿相关
【Copy攻城狮日志】飞浆学院强化学习7日打卡营-学习笔记
Pytorch问题总结
第三章 标准单元库(上)
AWS uses EC2 to reduce the training cost of DeepRacer: DeepRacer-for-cloud practical operation
MNIST手写数字识别 —— Lenet-5首个商用级别卷积神经网络









