发布于 3年前

tmux快捷键以及使用手册

开始新建tmux会话:

tmux

创建并指定会话名称

tmux new -s myname

挂载

tmux a

挂载在指定的名称会话上:

tmux a -t myname

列出所有会话:

tmux ls

杀掉会话:

tmux kill-session -t myname

杀掉所有tmux会话:

tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill

在tmux,输入ctrl+b,然后可以做以下操作:

会话

:new<CR>  new session
s  list sessions
$  name session

窗口/tag

c  create window
w  list windows
n  next window
p  previous window
f  find window
,  name window
&  kill window

窗口拆分

%  vertical split
"  horizontal split
o  swap panes
q  show pane numbers
x  kill pane
+  break pane into window (e.g. to select text by mouse to copy)
-  restore pane from window
⍽  space - toggle between layouts
<prefix> q (Show pane numbers, when the numbers show up type the key to goto that pane)
<prefix> { (Move the current pane left)
<prefix> } (Move the current pane right)
<prefix> z toggle pane zoom

同步窗口

可以切换到适当的窗口,输入Tmux前缀(通常为Ctrl-B或Ctrl-A),然后输入冒号以显示Tmux命令行,然后键入:

:setw synchronize-panes

可以选择添加或关闭。 否则,该选项将被简单地切换。 此选项特定于一个窗口,因此不会更改其他会话或窗口的操作方式。 完成后,通过重复命令再次将其关闭。

调整窗口的大小

PREFIX : resize-pane -D (Resizes the current pane down)
PREFIX : resize-pane -U (Resizes the current pane upward)
PREFIX : resize-pane -L (Resizes the current pane left)
PREFIX : resize-pane -R (Resizes the current pane right)
PREFIX : resize-pane -D 20 (Resizes the current pane down by 20 cells)
PREFIX : resize-pane -U 20 (Resizes the current pane upward by 20 cells)
PREFIX : resize-pane -L 20 (Resizes the current pane left by 20 cells)
PREFIX : resize-pane -R 20 (Resizes the current pane right by 20 cells)
PREFIX : resize-pane -t 2 20 (Resizes the pane with the id of 2 down by 20 cells)
PREFIX : resize-pane -t -L 20 (Resizes the pane with the id of 2 left by 20 cells)

复制模式

按下 [键,我们就会进入复印模式。 然后,我们可以使用移动键在屏幕上移动光标。 默认情况下,箭头键起作用。 我们将配置文件设置为使用Vim键在窗口之间切换和调整窗格大小,因此我们不必将手从首页移开。 tmux也具有vi模式,可用于缓冲区。 要启用它,请将此行添加到.tmux.conf。

setw -g mode-keys vi

设置此选项后,我们可以使用h,j,k和l在缓冲区中移动。

要退出复印模式,我们只需按ENTER键。一次移动一个字符不是很有效。由于启用了vi模式,因此我们还可以使用其他一些可见的快捷方式在缓冲区中移动。

例如,我们可以使用“ w”跳到下一个单词,使用“ b”跳回一个单词。并且我们可以使用“ f”,后跟任意字符,以在同一行上跳至该字符,并使用“ F”在该行上向后跳。

 Function                vi             emacs
   Back to indentation     ^              M-m
   Clear selection         Escape         C-g
   Copy selection          Enter          M-w
   Cursor down             j              Down
   Cursor left             h              Left
   Cursor right            l              Right
   Cursor to bottom line   L
   Cursor to middle line   M              M-r
   Cursor to top line      H              M-R
   Cursor up               k              Up
   Delete entire line      d              C-u
   Delete to end of line   D              C-k
   End of line             $              C-e
   Goto line               :              g
   Half page down          C-d            M-Down
   Half page up            C-u            M-Up
   Next page               C-f            Page down
   Next word               w              M-f
   Paste buffer            p              C-y
   Previous page           C-b            Page up
   Previous word           b              M-b
   Quit mode               q              Escape
   Scroll down             C-Down or J    C-Down
   Scroll up               C-Up or K      C-Up
   Search again            n              n
   Search backward         ?              C-r
   Search forward          /              C-s
   Start of line           0              C-a
   Start selection         Space          C-Space
   Transpose chars                        C-t

其他

d  detach
t  big clock
?  list shortcuts
:  prompt

配置项

# 鼠标支持-如果要使用鼠标,请设置为on
* setw -g mode-mouse off
* set -g mouse-select-pane off
* set -g mouse-resize-pane off
* set -g mouse-select-window off
# 将默认终端模式更改为256色模式
set -g default-terminal "screen-256color"
# 启用活动警报
setw -g monitor-activity on
set -g visual-activity on
# 将窗口列表居中
set -g status-justify centre
# 最大化和还原窗格e
unbind Up bind Up new-window -d -n tmp \; swap-pane -s tmp.1 \; select-window -t tmp
unbind Down
bind Down last-window \; swap-pane -s tmp.1 \; kill-window -t tmp
©2020 edoou.com   京ICP备16001874号-3