Avatar

Organizations

1 results for Tmux
  • 配置文件

    ; ~/.tmux.conf
    # 启动鼠标支持
    set -g mouse on
    set -g mode-keys vi
    
    # WindTerm需在 会话 --> 首选项 --> 设置 --> 终端 --> 鼠标追踪 --> 追踪事件
    # 取消勾选:
    # - 移动事件
    # - 点击事件
    # - 右键单击事件
    # WindTerm使用鼠标修改面板大小,受WindTerm限制无法实现
    
    # 禁用 WindTerm 的默认鼠标行为(防止冲突)
    set -g terminal-overrides 'xterm*:smcup@:rmcup@'
    # 1. 禁用左键释放自动复制(改为仅选择)
    bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-selection-and-cancel
    # 2. 右键复制已选文本(需先左键选择)
    bind -T copy-mode-vi MouseDown3Pane send-keys -X copy-pipe-and-cancel \
      "xclip -i -selection clipboard 2>/dev/null || \
       pbpaste 2>/dev/null || \
       win32yank.exe -i 2>/dev/null"
    # 3. 右键直接粘贴系统剪贴板内容(跨系统支持)
    bind -n MouseDown3Pane run-shell \
      "tmux set-buffer -- \"$(xclip -o -selection clipboard 2>/dev/null || \
                              pbpaste 2>/dev/null || \
                              win32yank.exe -o 2>/dev/null)\"; \
       tmux paste-buffer"
    
    # 解除默认的鼠标调整绑定(可选)
    unbind-key -T root MouseDrag1Border
    # 重新绑定鼠标拖动调整大小
    bind -n MouseDrag1Border resize-pane -M
    
    # status line
    set -g status-justify centre
    set -g status-left "#{session_name}"
    set -g status-right "%F %R"
    # 窗口编号自动重新排序
    set -g renumber-windows on
    
    # status line > window list
    set -g window-status-format "#{window_index}:#{window_name}"
    set -g window-status-separator " | "
    set -g window-status-current-format "#{window_index}:#{window_name}"
    set -g window-status-current-style bold,italics
    
    # pane
    set -g pane-border-format " #{pane_index}:#{pane_title} $ #{pane_current_command} "
    set -g pane-border-status top
    set -g history-limit 10000
    
    # 更新配置,不需要关闭tmux,直接运行马上生效
    tmux source-file ~/.tmux.conf
    

    快捷键操作

    Prefix = Ctrl + b

    cli tmux linux Created Wed, 21 Feb 2024 16:08:32 +0800