tmux | 使用手册 (cheat sheet)

Cheatsheet: tmux,
参考

  • https://www.outcoldman.com/cheatsheets/tmux/
  • https://gist.github.com/noku/ceb09028b815034e41c1

Command line

tmux new -s {session_name} -n {name} - create new session and specify window name
tmux {attach|a|at} -t {session_name} - attach to session
tmux ls - list sessions
tmux kill-session -t {session_name} - kill session

Misc

Prefix ? - help
Prefix d - detach
Prefix t - big clock

Command mode

Prefix : - command mode
new-window -n {name} {command} - create new window and execute command

Sessions

:new - new session
Prefix s - list sessions
Prefix $ - name session
Prefix ( - previous session
Prefix ) - next session
Prefix L - last session

Windows

Prefix c - create new window
Prefix , - rename window
Prefix n - next window
Prefix p - previous window
Prefix {n} - go to window n
Prefix f - find window by name
Prefix w - list windows
Prefix & - kill window

Panes

Prefix % split panes by vertical (see tmux-pain-control)
Prefix " split panes by horizontal (see tmux-pain-control)
Prefix o - cycle through the panes
Prefix {arrow key} - navigate to specific pane (see tmux-pain-control)
Prefix space - cycle thought layouts
Prefix x - close pane
Prefix q - show panes numbers
Prefix z - switch to whole window mode and back
Prefix { - move the current pane left (see tmux-pain-control)
Prefix } - move the current pane right (see tmux-pain-control)
:setw synchronize-panes - toggle panes synchronization

Copy mode (vi mode)

Prefix [ - start copy mode
Prefix ] - past from copy mode
^ - back to indentation
esc - clear selection
enter - copy selection
j - cursor down
h - cursor left
l - cursor right
k - cursor down
L - cursor to bottom line
M - cursor to middle line
H - cursor to top line
d - delete entire line
D - delete to end of line
$ - end of line
: - goto line
⌃-d - half page down
⌃-u - half page up
⌃-f - next page
w - next word
p - paste buffer
⌃-b - previous page
b - previous word
q - quit mode
⌃-down, ⌃-j - scroll down
⌃-up, ⌃-k - scroll up
n - next search match
? - search backward
/ - search forward
0 - start of line
space - start selection
使用vi的方式在copy mode移动

将设置setw -g mode-keys vi在配置文件~/.tmux.conf写上
然后tmux source ~/.tmux.conf
使用命令如下

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

Settings

set -g mode-mouse on - enable mouse support

Plugins

tmux-copycat

https://github.com/tmux-plugins/tmux-copycat

prefix + / - regex search (strings work too)
Predefined searches
prefix + ctrl-f - simple file search
prefix + ctrl-g - jumping over git status files (best used after git status command)
prefix + alt-h - jumping over SHA-1 hashes (best used after git log command)
prefix + ctrl-u - url search (http, ftp and git urls)
prefix + ctrl-d - number search (mnemonic d, as digit)
prefix + alt-i - ip address search
tmux-open

https://github.com/tmux-plugins/tmux-open

o - “open” a highlighted selection with the system default program. open for OS X or xdg-open for Linux.
⌃-o - open a highlighted selection with the $EDITOR
tmux-pain-control

https://github.com/tmux-plugins/tmux-pain-control

Navigation

Prefix + h, Prefix + C-h - select pane on the left
Prefix + j, Prefix + C-j - select pane below the current one
Prefix + k, Prefix + C-k - select pane above
Prefix + l, Prefix + C-l - select pane on the right

Resizing

Prefix + shift + h - resize current pane 5 cells to the left
Prefix + shift + j - resize 5 cells in the up direction
Prefix + shift + k - resize 5 cells in the down direction
Prefix + shift + l - resize 5 cells to the right

Splitting

Prefix | split panes by vertical
Prefix - split panes by horizontal

Swapping panes

Prefix < moves current pane one position to the left
Prefix > moves current pane one position to the right
tmux-resurrect

https://github.com/tmux-plugins/tmux-resurrect

Prefix ⌃-s - save
Prefix ⌃-r - restore
tmux-yank

https://github.com/tmux-plugins/tmux-yank

Prefix - y - copies text from the command line to clipboard
**copy mode**
y - copy selection to system clipboard
Y - copy selection and paste it to the command line
vim-tmux-navigator

https://github.com/christoomey/vim-tmux-navigator

⌃-h - Left
⌃-j - Down
⌃-k - Up
⌃-l - Right
⌃-\ - Previous split
tmuxinator

https://github.com/tmuxinator/tmuxinator

tmux-sensible

https://github.com/tmux-plugins/tmux-sensible

tpm

https://github.com/tmux-plugins/tpm

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是 tmux 的使用文档。 # 什么是 Tmux Tmux 是一个终端复用工具,它可以让你在单个终端窗口中同时运行多个终端会话,并且可以在不同的会话之间切换。 # 安装 Tmux 在 Linux 上安装 Tmux 可以使用以下命令: ```shell sudo apt-get install tmux # Debian/Ubuntu sudo yum install tmux # CentOS/RHEL ``` # Tmux 基础用法 ## 启动 Tmux 启动 Tmux 可以使用以下命令: ```shell tmux ``` ## Tmux 快捷键 Tmux 的所有操作都是通过快捷键来完成的。下面是一些常用的快捷键: - `Ctrl-b ?` 显示快捷键帮助 - `Ctrl-b c` 创建一个新窗口 - `Ctrl-b n` 切换到下一个窗口 - `Ctrl-b p` 切换到上一个窗口 - `Ctrl-b d` 断开当前会话 - `Ctrl-b [0-9]` 切换到指定编号的窗口 - `Ctrl-b "` 水平分割当前窗口 - `Ctrl-b %` 垂直分割当前窗口 ## Tmux 窗口和面板 Tmux 中的窗口和面板类似于屏幕上的分隔符,您可以使用它们将屏幕分成多个区域。 ### 窗口 Tmux 中的窗口是您可以在其中运行应用程序的虚拟终端。默认情况下,Tmux 启动一个窗口,但您可以创建多个窗口。 创建新窗口:`Ctrl-b c` 切换到下一个窗口:`Ctrl-b n` 切换到上一个窗口:`Ctrl-b p` 切换到指定编号的窗口:`Ctrl-b [0-9]` ### 面板 Tmux 中的面板类似于窗口,但它们是窗口的子区域。您可以在面板中运行应用程序,就像在窗口中一样。 水平分割当前窗口:`Ctrl-b "` 垂直分割当前窗口:`Ctrl-b %` 切换到下一个面板:`Ctrl-b o` 在面板之间移动:`Ctrl-b 方向键` 关闭当前面板:`Ctrl-b x` ### Tmux 命令 Tmux 的命令可以通过 `Ctrl-b :` 来输入。 例如: - 保存当前 Tmux 会话:`Ctrl-b :save-buffer /path/to/file` - 加载之前保存的 Tmux 会话:`Ctrl-b :source-file /path/to/file` # 总结 Tmux 可以让你在一个终端窗口中同时运行多个终端会话,这在日常工作中非常有用。掌握 Tmux 的基本用法对于 Linux 用户来说是非常重要的。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值