当前位置: 首页 > 工具软件 > tmux-yank > 使用案例 >

tmux | 使用手册 (cheat sheet)

濮丁雷
2023-12-01

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

 类似资料: