tmux

https://tmuxcheatsheet.com/

image-20230922234753859

前缀prefix:ctrl b

创建新窗口:pre+c

切换窗口:pre+number,或pre+p pre+n

关闭窗口:pre+&

左右分屏:pre+%

上下分屏:pre+“

关闭分屏:pre+x

最大化分屏:pre+z

切换分屏:pre+方向键或pre+q+number

空间预览:pre+w

脱离工作空间detached:pre+d

连接工作空间attach:tmux a (tmux attach)

查看所以工作空间:tmux ls

连接指定工作空间:tmux attach -t [number]

~/.tmux.conf

set-option -sa terminal-overrides ",xterm*:Tc"
set -g default-terminal "screen-256color"
set-option -ga terminal-overrides ",*256col*:Tc"
setw -g mode-keys vi
set -g status-keys vi
# set-option default-path "$PWD"
set -s escape-time 0
set -sg repeat-time 300
set -s focus-events on
set -g mouse on
unbind -T copy-mode-vi MouseDragEnd1Pane
bind v copy-mode # 绑定esc键为进入复制模式
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel
# buffer缓存复制到Linux系统粘贴板
bind C-c run " tmux save-buffer - | xclip -i -sel clipboard"
# Linux系统粘贴板内容复制到会话
bind C-v run " tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"
set -sg exit-empty on
set -q -g status-utf8 on
set -g history-limit 5000
setw -q -g utf8 on
set -g visual-activity off
setw -g monitor-activity off
setw -g monitor-bell off
# 使用 Ctrl + b + hjkl
bind h select-pane -L # 定位到左边窗口的快捷键
bind j select-pane -D # 定位到上边窗口的快捷键
bind k select-pane -U # 定位到下方窗口的快捷键
bind l select-pane -R # 定位到右边窗口的快捷键
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
bind -r H resize-pane -L 5
bind -r m resize-pane -Z
#绑定|左右分屏 -上下分屏
unbind %
bind | split-window -h
unbind '"'
bind _ split-window -v
#pulg
set -g @plugin 'tmux-plugins/tpm'
#ctrl +hjkl 不同Pane移动
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'jimeh/tmux-themepack'
set -g @plugin 'tmux-plugins/tmux-resurrect' # persist tmux sessions after computer restart
set -g @plugin 'tmux-plugins/tmux-continuum' # automatically saves sessions for you every 15 minutes
set -g @resurrect-capture-pane-contents 'on'
set -g @themepack 'powerline/block/green'
# set -g status-right 'Continuum status: #{continuum_status}'
run '~/.tmux/plugins/tpm/tpm' # Initialize Tmux plug manger