【shell】Tmux 快捷键入门

Tmux:终端复用器(terminal multiplexer)

类似于screen

需要安装:

# Ubuntu/Debian
$ sudo apt-get install tmux

# CentOS/Fedora
$ sudo yum install tmux

# MacOS
$ brew install tmux

需要知道的构造:

  • session
  • window
  • pane

tmux expects you to know its keybindings, and they all have the form x where that means (1) press Ctrl+b, (2) release Ctrl+b, and then (3) press x. tmux has the following hierarchy of objects:

Sessions - a session is an independent workspace with one or more windows
tmux starts a new session.
tmux new -s NAME starts it with that name.
tmux ls lists the current sessions
Within tmux typing d detaches the current session
tmux a attaches the last session. You can use -t flag to specify which
Windows - Equivalent to tabs in editors or browsers, they are visually separate parts of the same session
Panes - Like vim splits, panes let you have multiple shells in the same visual display.

$ tmux #新建 session
^+b d #键盘 detach
[detached (from session 0)]
$ tmux new -t foobar #新建 带名儿
^+b d #键盘 detach
[detached (from session foobar-1)]
$ tmux ls #查看现有的sessions
0: 1 windows (created Wed Aug 19 00:32:46 2020)
foobar-1: 1 windows (created Wed Aug 19 00:33:27 2020) (group foobar)
$ tmux a -t 0 #重新连接
^+b d #键盘 detach
[detached (from session 0)]
$ tmux a -t foobar #重新连接
^+d #键盘 关闭 
[exited]

windows的新建和切换
举例,当前window下,按:
^+b c #新建一个
^+b c #再新建一个

^+b p #切换上一个, previous
^+b n #切换下一个 , next
^+b 0 #回最初的那个
^+b 1 #回新建的一号
^+b 2 #回新建的二号

pane的新建和切换
^+b " #在下面开新pane
^+b % #在右边开新pane
^+b⬆️ #切换到上面
^+b⬇️ #切换到下面
^+b⬅️ #切换到左边
^+b➡️ #切换到右边

如图:绿色的那栏里面的0,1,2 就是windows的编号
【shell】Tmux 快捷键入门_第1张图片

^+bspace #一键整洁,如图:

^+bspace #一键整洁,如图:

这一个keybinding,有5种layout,每次都不一样,可重复调试自己喜欢的样纸~

^+bz # 全屏当前pane, zoom
^+bz # 再来一下,恢复

^+bw #上帝视角,如图:
【shell】Tmux 快捷键入门_第2张图片

滑动:
^+b[ #可以滑动了
q #退出此模式

改名字:

^+b$ #改session的名字
^+b, #改window的名字,但貌似只适用于此window只有一个pane。。

帮助:
^+b? #显示所有keybindings

C-b C-b     Send the prefix key
C-b C-o     Rotate through the panes   
C-b C-z     Suspend the current client 
C-b Space   Select next layout         
C-b !       Break pane to a new window 
C-b "       Split window vertically    
C-b #       List all paste buffers     
C-b $       Rename current session     
C-b %       Split window horizontally  
C-b &       Kill current window        
C-b '       Prompt for window index to select
C-b (       Switch to previous client  
C-b )       Switch to next client      
C-b ,       Rename current window      
C-b -       Delete the most recent paste buffer
C-b .       Move the current window    
C-b /       Describe key binding       
C-b 0       Select window 0            
C-b 1       Select window 1            
C-b 2       Select window 2            
C-b 3       Select window 3            
C-b 4       Select window 4            
C-b 5       Select window 5            
C-b 6       Select window 6                           
C-b 7       Select window 7                           
C-b 8       Select window 8                           
C-b 9       Select window 9                           
C-b :       Prompt for a command                      
C-b ;       Move to the previously active pane
C-b =       Choose a paste buffer from a list
C-b ?       List key bindings                         
C-b D       Choose a client from a list               
C-b E       Spread panes out evenly                   
C-b L       Switch to the last client                 
C-b M       Clear the marked pane                     
C-b [       Enter copy mode                           
C-b ]       Paste the most recent paste buffer
C-b c       Create a new window                       
C-b d       Detach the current client                 
C-b f       Search for a pane                         
C-b i       Display window information                
C-b l       Select the previously current window
C-b m       Toggle the marked pane                    
C-b n       Select the next window                    
C-b o       Select the next pane                      
C-b p       Select the previous pane   C-b q       Display pane numbers                      
C-b r       Redraw the current client                 
C-b s       Choose a session from a list
C-b t       Show a clock                              
C-b w       Choose a window from a list               
C-b x       Kill the active pane                      
C-b z       Zoom the active pane                      
C-b {       Swap the active pane with the pane above
C-b }       Swap the active pane with the pane below
C-b ~       Show messages                             
C-b DC      Reset so the visible part of the window follows the cursor
C-b PPage   Enter copy mode and scroll up
C-b Up      Select the pane above the active pane
C-b Down    Select the pane below the active pane
C-b Left    Select the pane to the left of the active pane
C-b Right   Select the pane to the right of the active pane
C-b M-1     Set the even-horizontal layout
C-b M-2     Set the even-vertical layout
C-b M-3     Set the main-horizontal layout
C-b M-4     Set the main-vertical layout
C-b M-5     Select the tiled layout                   
C-b M-n     Select the next window with an alert
C-b M-o     Rotate through the panes in reverse
C-b M-p     Select the previous window with an alert
C-b M-Up    Resize the pane up by 5                   
C-b M-Down  Resize the pane down by 5                 
C-b M-Left  Resize the pane left by 5                 
C-b M-Right Resize the pane right by 5                
C-b C-Up    Resize the pane up                        
C-b C-Down  Resize the pane down                      
C-b C-Left  Resize the pane left                      
C-b C-Right Resize the pane right                     
C-b S-Up    Move the visible part of the window up
C-b S-Down  Move the visible part of the window down
C-b S-Left  Move the visible part of the window left
C-b S-Right Move the visible part of the window right

你可能感兴趣的:(tricks,linux,tmux,快捷键)