歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> Linux tmux學習筆記

Linux tmux學習筆記

日期:2017/3/1 17:01:54   编辑:關於Linux
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的窗口
Copyright © Linux教程網 All Rights Reserved