本文记录tmux的使用方法,为了方便查阅:
# 启动一个
tmux
# 指定session名字
tmux new -s session-name
exit
ctrl + d
tmux ls
# 保持后台运行
ctrl + b, d
tmux attach -t session-name
ctrl + b, c
ctrl + b, 窗口编号
tmux rename-session -t <old_name> <new_name>
# 水平分割
ctrl + b, "
# 垂直分割
ctrl + b, %
# 按顺序切换到下一个pane
ctrl + b, o
# 方向键切换pane
ctrl + b, 方向键
# 按编号切换pane
ctrl + b, q
# 修改.tmux.conf文件
set -g default-terminal "screen-256color"
set-option -g mouse on
set-option -g renumber-windows on
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-yank'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
# 可以用htop/top来看,但是那不方便,可以把这个功能嵌入到tmux里面
set -g status-interval 2
set -g status-right "#[fg=green]CPU: #(bash -c 'read a b c d e f g h i j < /proc/stat; sleep 0.3; read a2 b2 c2 d2 e2 f2 g2 h2 i2 j2 < /proc/stat; idle=$((d+e)); idle2=$((d2+e2)); total=$((b+c+d+e+f+g+h+i)); total2=$((b2+c2+d2+e2+f2+g2+h2+i2)); echo $(( (100*( (total2-total)-(idle2-idle) )) / (total2-total) ))%') #[fg=cyan]| MEM: #(free -h | awk '/Mem:/ {print $3 \"/\" $2}') #[fg=yellow]| %H:%M "
ctrl + b, :set synchronize-panes
ctrl + b, :set synchronize-panes off