在 tmux 中启用鼠标与 X 中的粘贴冲突

Bar*_*den 3 mouse gnome tmux

这个问题与tmux类似但不完全相同——有什么方法可以启用滚动,但不能选择?

我在 gnome-terminal 中使用 tmux。当我setw -g mode-mouse on在 tmux 中使用滚动历史缓冲区时,tmux 不考虑 X 中的复制/粘贴功能,即选择文本不会将文本放在主缓冲区中,并且我无法使用鼠标中键进行粘贴

当我按下鼠标中键时,我看到屏幕右上角的坐标——看起来它试图将鼠标中键点击注册为使用滚轮。

我可以使用 tmux 设置来解决这个问题吗?滚轮和鼠标中键在 tmux 中是否被视为独立的?我可以将鼠标中键映射到操作系统粘贴吗?tmux 可以从/馈送操作系统复制/粘贴请求吗?

dem*_*ure 6

快的

在 OS X 上,(使用 iTerm2)我必须按住 shift + alt 来临时覆盖 tmux 的鼠标控制。您的终端模拟器可能具有类似的能力。

能用,但是麻烦

除此之外,您可以关闭鼠标支持,使用系统剪贴板复制文本,然后重新打开。从我的~/.tmux.conf

### Mouse On/Off ### {{{
## Mouse On by default
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on

##Toggle mouse on with <prefix>m
bind m \
        set -g mode-mouse on \;\
        set -g mouse-resize-pane on \;\
        set -g mouse-select-pane on \;\
        set -g mouse-select-window on \;\
        display 'Mouse: ON'

## Toggle mouse off with <prefix>M
bind M \
        set -g mode-mouse off \;\
        set -g mouse-resize-pane off \;\
        set -g mouse-select-pane off \;\
        set -g mouse-select-window off \;\
        display 'Mouse: OFF'
### End Mouse On/Off ### }}}
Run Code Online (Sandbox Code Playgroud)

可能更好

你也可以让 tmux yank 进入你的系统剪贴板:

# move x clipboard into tmux paste buffer
bind C-p run "tmux set-buffer \"$(xclip -o)\"; tmux paste-buffer"
# move tmux copy buffer into x clipboard
bind C-y run "tmux save-buffer - | xclip -i"
Run Code Online (Sandbox Code Playgroud)

哪里xclip可以替换为您的选择。如果在远程服务器上完成,最后一个将需要 X 转发。

  • 按住 Shift+Alt 效果很好。 (2认同)