Tmux
出自 Chan
目錄
Common Shortcuts
# start new session
tmux new -s myname
# list sessions
tmux ls
# attach to session
tmux a -t 0
# rename session
tmux rename-session -t 0 NEW_NAME
# kill session
tmux kill-session -t 0
Windows Control
- <prefix> c create window
- <prefix> w list windows
- <prefix> n next window
- <prefix> p previous window
- <prefix> f find window
- <prefix> , name window
- <prefix> & kill window
- <prefix> [ check history
Pane Control
- <prefix> % vertical split
- <prefix> " horizontal split
- <prefix> o swap panes
- <prefix> q show pane numbers
- <prefix> x kill pane
- <prefix> q (Show pane numbers, when the numbers show up type the key to goto that pane)
- <prefix> { (Move the current pane left)
- <prefix> } (Move the current pane right)
- <prefix> z toggle pane zoom
Resize Pane
<prefix> : resize-pane -D (Resizes the current pane down)
<prefix> : resize-pane -U (Resizes the current pane upward)
<prefix> : resize-pane -L (Resizes the current pane left)
<prefix> : resize-pane -R (Resizes the current pane right)
<prefix> : resize-pane -D 20 (Resizes the current pane down by 20 cells)
<prefix> : resize-pane -U 20 (Resizes the current pane upward by 20 cells)
<prefix> : resize-pane -L 20 (Resizes the current pane left by 20 cells)
<prefix> : resize-pane -R 20 (Resizes the current pane right by 20 cells)
<prefix> : resize-pane -t 2 20 (Resizes the pane with the id of 2 down by 20 cells)
<prefix> : resize-pane -t -L 20 (Resizes the pane with the id of 2 left by 20 cells)
Start With Configuration
#!/bin/bash
tmux -2 new-session \; \
send-keys 'cd /var/www/test; vim' C-m \; \
split-window -h \; \
send-keys 'top' C-m \; \
resize-pane -R 30 \; \
split-window -v \; \
send-keys 'while true; do date; sleep 1; done' C-m \; \
My Config
先安裝 tpm https://github.com/tmux-plugins/tpm
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# ~/.tmux.conf
setw -g mode-keys vi
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'dracula/tmux'
set -g @dracula-plugins "git cpu-usage ram-usage time"
set -g @dracula-show-powerline true
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'
# ~/.bashrc
alias tmux='tmux -2'
Reference Site
https://gist.github.com/MohamedAlaa/2961058
https://blog.htbaa.com/news/tmux-scripting