# tmux 筆記 ## 指令 預設的 prefix 為 C-b, 後方設定檔改為 C-a, 所以下列指令都以 C-a 來標示 |指令|用途| |:---|:--| |tmux |建立 tmux session, 名稱會從 0,1,2,3...etc 循序編下去| |tmux new -t [NAME]|建立指定名稱的 tmux session| |tmux ls |列出目前所有可存取的 session| |tmux attach -t [NAME] | attach 可存取的 session| |C-a + d | detach 當下使用的 session| |C-a + c | 新增一個 panel 到另一個 tab | |C-a + x | 關閉目前的 panel| |C-a + " | 水平分割視窗 | |C-a + % | 垂直分割視窗 | |Alt + 0-9| 切換 tab | |C-a + k | 切換到上方視窗 | |C-a + j | 切換到下方視窗 | |C-a + h | 切換到左方視窗 | |C-a + l | 切換到右方視窗 | |C-a + K | 調整視窗朝上方放大 | |C-a + J | 調整視窗朝下方放大 | |C-a + H | 調整視窗朝左方放大 | |C-a + L | 調整視窗朝右方放大 | ## 設定檔 - 常用的 .tmux.conf ```bash set -g prefix C-a unbind-key C-b bind-key C-a send-prefix # set -g status-bg colour159 set-option -g status-fg white set-option -g status-bg blue # Toggle mouse on/off bind m set-option -g mouse on bind M set-option -g mouse off # switch windows alt+number bind-key -n M-1 select-window -t 0 bind-key -n M-2 select-window -t 1 bind-key -n M-3 select-window -t 2 bind-key -n M-4 select-window -t 3 bind-key -n M-5 select-window -t 4 bind-key -n M-6 select-window -t 5 bind-key -n M-7 select-window -t 6 bind-key -n M-8 select-window -t 7 bind-key -n M-9 select-window -t 8 bind-key -n M-0 select-window -t 9 bind -r H resize-pane -L 5 bind -r J resize-pane -D 5 bind -r K resize-pane -U 5 bind -r L resize-pane -R 5 bind h select-pane -L bind j select-pane -D bind k select-pane -U bind l select-pane -R bind -r C-h select-window -t :- bind -r C-l select-window -t :+ ``` - 如何讓tmux新開視窗在同一個目錄中 ```bash # add below setting to .tmux.conf bind c new-window -c "#{pane_current_path}" bind '"' split-window -c "#{pane_current_path}" bind % split-window -h -c "#{pane_current_path}" ``` - 如何使用不同的 tmux.conf 設定執行 *When used without options, prevents the client from exiting until woken using wait-for -S with the same channel. When -L is used, the channel is locked and any clients that try to lock the same channel are made to wait until the channel is unlocked with wait-for -U.* 可以使用 -L 參數設定不同的 channel, 每個channel可以使用不同的設定檔, 上面可以建立多個tmux instance. ``` tmux -L [channel name] -f tmux.conf ``` ## 參考網頁 - https://github.com/tmux/tmux/wiki/Getting-Started - https://blog.gtwang.org/linux/linux-tmux-terminal-multiplexer-tutorial/
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up