Linux tmux學習筆記

來源:互聯網
上載者:User

Linux tmux學習筆記 tmux號稱screen的替代品,來看看為什麼這麼說: 支援多個window之間的粘貼/複製,可以選擇粘貼緩衝區,而這screen不支援。分屏操作完勝。screen只支援簡陋的上下分屏,分屏後還需要ctrl+a+c才能建立一個新的終端。screen直接建立一個終端,且支援螢幕之間的切換/relocate/重定義大小,以及提供了一些預置的layout  www.2cto.com  tmux預設內建status bar,screen還需手動設定tmux的配置比screen簡單vi和emac模式綁定                                                     啟動tmux: tmux ls: list tmux session tmux attach: attach a tmux session  tmux啟動參數: -c: shell-command, 比如 tmux -c vim-f file: 指定設定檔,預設~/.tmux.conf,或者/etc/tmux.conf-L socket-name: 制定tmux session的名字-u: 支援utf-8-V: version  www.2cto.com  tmux的一些概念:  A session is a single collection of pseudo terminals under the management of tmux.  Each session has one or more      windows linked to it.  A window occupies the entire screen and may be split into rectangular panes, each of      which is a separate pseudo terminal (the pty(4) manual page documents the technical details of pseudo termi‐      nals).  Any number of tmux instances may connect to the same session, and any number of windows may be present      in the same session.  Once all sessions are killed, tmux exits.  session: 會話,一個伺服器可以包含多個session window: 視窗,一個session可以包含多個window pane: 面板,一個window可以包含多個pane  tmux 配置: tmux預設的bind-key是ctrl + b,可以修改為習慣的ctrl+a: set -g prefix ^a unbind ^b bind a send-prefix  設定之後,ctrl+a+a可以在terminal中將游標一到行首  Vim代碼  set-option -g display-time 4000                                                   set-option -g status-keys vi                                                      set-window-option -g mode-keys vi                                               # set default bind-key to ctrl + a                                                set-option -g prefix C-a                                                          unbind-key C-b                                                                    bind-key C-a send-prefix                                                      # unbind '"'                                                                      bind - splitw -v # 分割成上下兩個視窗                                             # unbind %                                                                        bind | splitw -h # 分割成左右兩個視窗                                                                                                                    bind k selectp -U # 選擇上窗格                                                    bind j selectp -D # 選擇下窗格                                                    bind h selectp -L # 選擇左窗格                                                    bind l selectp -R # 選擇右窗格                                                 bind-key J resize-pane -D 10                                                      bind-key K resize-pane -U 10                                                      bind-key H resize-pane -L 10                                                      bind-key L resize-pane -R 10                                                  bind ^u swapp -U # 與上窗格交換 Ctrl-u                                            bind ^d swapp -D # 與下窗格交換 Ctrl-d  bind ^u swapp -U # 與上窗格交換 Ctrl-u                                            bind ^d swapp -D # 與下窗格交換 Ctrl-d                                        bind m command-prompt "splitw -h 'exec man %%'"                                                                                                       #定製狀態行                                                                       #狀態行左邊預設就很好了,我對右邊定製了一下,顯示 uptime 和 loadavg:        #set -g status-right "#[fg=green]#(uptime.pl)#[default] • #[fg=green]#(cut -d ' ' -f 1-3 /proc/loadavg)#[default]"                                                                              # 下面兩行設定狀態行的背景和前景色彩:                                               set -g status-bg black                                                            set -g status-fg yellow                                                           #預設啟動應用                                                                     #當 tmux 啟動時,可以預設啟動一些應用:                                           #new -s work  # 建立名為 work 的會話,並啟動 mutt                                 #neww rtorrent # 啟動 rtorrent                                                    #neww vim # 啟動 vim                                                              #neww sh                                                                          #selectw -t 1 # 預設選擇標號為1的視窗   

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.