Linux tmux

quickstart

tmux new -s name # tmux new-session -s name
tmux rename -t old new
tmux ls
tmux at -t name
tmux kill-session -t name
tmux kill-window -t name


Ctrl-b d # 后台会话
Ctrl-b [ # 滚屏查看
Ctrl-b c # 新建窗口 Ctrl-b & # 关闭窗口
Ctrl-b n/p # 切换窗口

三个基本概念

概念描述
Session会话,相当于开了一个ssh
Window窗口,相当于在这个ssh中开了多个shell,有标签tab的形式
Panel面板,相当于在tab标签中开了多个面板(就是分割了当前的屏幕)

Window和Panel本质上是一样的,知识分割shell的方式不同

命令

位置操作命令
新建会话tmux new -s name
列出会话tmux ls
关闭会话tmux kill-session -t session-name|mux kill-server(关闭所有)
进入会话tmux attach -t name
关闭会话exit
跳转tmux switch -t name
后台会话tmux detach(快捷键d)

外和内是指在seesion外还是在session内

快捷键

快捷键的开始首先需要在session中按ctrl+b,然后再按相应的快捷键.
例如:tmux detach快捷键是d,那么需要先按ctrl+b,然后再按d

Session

快捷键命令
s列出会话,并选择
$重命名会话
d后台会话

window

快捷键命令
w列出窗口,并选择
c创建窗口
,重命名窗口
n选择下一个窗口
p选择上一个窗口
0~9选择0~9对应的窗口

Pane

快捷键命令
%竖分
"横分
q显示窗格的编号
o在窗格间切换
}与下一个窗格交换位置
{与上一个窗格交换位置
!在新窗口中显示当前窗格
x关闭当前窗格
上下左右选择相应的Pane
c-上,c-下,c-左,c-右调整Pane的大小

快捷键

快捷键描述
C-bSend the prefix key (C-b) through to the application.
C-oRotate the panes in the current window forwards.
C-zSuspend the tmux client.
!Break the current pane out of the window.
"Split the current pane into two, top and bottom.
#List all paste buffers.
$Rename the current session.
%Split the current pane into two, left and right.
&Kill the current window.
Prompt for a window index to select.
(Switch the attached client to the previous session.
)Switch the attached client to the next session.
,Rename the current window.
-Delete the most recently copied buffer of text.
0Prompt for an index to move the current window.
0 to 9Select windows 0 to 9.
:Enter the tmux command prompt.
;Move to the previously active pane.
=Choose which buffer to paste interactively from a list.
?List all key bindings.
DChoose a client to detach.
LSwitch the attached client back to the last session.
[Enter copy mode to copy text or view the history.
]Paste the most recently copied buffer of text.
cCreate a new window.
dDetach the current client.
fPrompt to search for text in open windows.
iDisplay some information about the current window.
lMove to the previously selected window.
nChange to the next window.
oSelect the next pane in the current window.
pChange to the previous window.
qBriefly display pane indexes.
rForce redraw of the attached client.
mMark the current pane (see select-pane -m).
MClear the marked pane.
sSelect a new session for the attached client interactively
tShow the time.
wChoose the current window interactively.
xKill the current pane.
zToggle zoom state of the current pane.
{Swap the current pane with the previous pane.
}Swap the current pane with the next pane.
~Show previous messages from tmux, if any.
Page UpEnter copy mode and scroll one page up.
Up,Down,Left,RightChange to the pane above, below, to the left, or to the right of the current pane.
M-1 to M-5Arrange panes in one of the five preset layouts: even-horizontal, even-vertical, main-horizontal, main-verti‐cal, or tiled.
SpaceArrange the current window in the next preset layout.
M-nMove to the next window with a bell or activity marker.
M-oRotate the panes in the current window backwards.
M-pMove to the previous window with a bell or activity marker.
C-Up, C-Down, C-Left, C-RightResize the current pane in steps of one cell.
M-Up, M-Down, M-Left, M-RightResize the current pane in steps of five cells.

命令

#管理客户端和会话

###attach
attach-session [-dEr] [-c working-directory] [-t target-session](alias: attach)
如果在tmux外执行,则会新建一个客户端,并进入;如果在tmux内部,则之间切换相应的会话。-d,使其他使用这个会话的客户端推出。-r,开启只读模式

detach

detach-client [-P] [-a] [-s target-session] [-t target-client](alias: detach)

has

has-session [-t target-session](alias: has)
报告是否存在对话

kill-server

杀死所有会话

kill-session

kill-session [-a] [-t target-session]
杀死所有会话,-a杀死除了指定的之外的会话

lsc

list-clients [-F format] [-t target-session](alias: lsc)
列出所有的客户端

lscm

list-commands(alias: lscm)
列出所有的命令

ls

list-sessions [-F format](alias: ls)
列出所有的会话

lockc

lock-client [-t target-client](alias: lockc)
锁定客户端

locks

lock-session [-t target-session]
锁定所有会话的客户端(alias: locks)

new

new-session [-AdDEP] [-c start-directory] [-F format] [-n window-name][-s session-name] [-t target-session] [-x width] [-y height][shell-command](alias: new)
创建一个新的会话

refresh

refresh-client [-S] [-t target-client](alias: refresh)
刷新客户端信息

rename

rename-session [-t target-session] new-name(alias: rename)
重新命名会话

showmsgs

show-messages [-IJT] [-t target-client](alias: showmsgs)

source

source-file path(alias: source)
从路径上执行命令

start

start-server(alias: start)
开启tmux服务,不会建立会话

suspendc

suspend-client [-t target-client](alias: suspendc)
挂起客户端

switchc

switch-client [-Elnpr] [-c target-client] [-t target-session] [-Tkey-table](alias: switchc)
切换客户端

其他

其他命令建议用快捷键

http://blog.jobbole.com/87584/

http://blog.jobbole.com/87278/

http://www.linuxidc.com/Linux/2015-07/119843.htm
比较详细
http://blog.csdn.net/u011138533/article/details/53109247

http://blog.csdn.net/u014015972/article/details/51611817
官方网站
https://robots.thoughtbot.com/a-tmux-crash-course

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值