【问题标题】:How do I scroll in tmux using the mouse?如何使用鼠标在 tmux 中滚动?
【发布时间】:2014-06-04 00:12:09
【问题描述】:

我在 Mac OS X 1.9.3 上使用 Apple 魔术鼠标在 Terminal.app 中使用 tmux 1.8。我也在使用 oh-my-zsh。

当 tmux 运行时,我根本无法用鼠标滚动。它只是向上滚动整个终端窗口,超出了 tmux 的输出。

我已经在 tmux.conf 文件中尝试了这些设置,但没有任何效果:

set -g mode-mouse on
setw -g mode-mouse on
set -g terminal-overrides 'xterm*:smcup@:rmcup@' 

我确保重新加载 tmux.conf 并终止了一个会话并创建了新的会话以确保。而且还是不行。

请帮忙。这是我的整个 tmux.conf

set -g default-terminal "xterm-256color"
set -g history-limit 10000
set -g status-interval 60

# status config
set -g status-utf8 on
set -g status-position top
set -g status-fg colour15
set -g status-bg colour24


# status line left side
set -g status-left-length 40
set -g status-left "#[fg=colour214,bold] #S #[fg=colour45] "

# status line right side
set -g status-right "#(~/.dotfiles/bin/tmux_battery_status) | %I:%M %p | %D "

# no more machine counting
set -g base-index 1
setw -g pane-base-index 1

# enable activity alerts
setw -g monitor-activity on
set -g visual-activity on

# window list colors
setw -g window-status-fg colour250
setw -g window-status-bg default
setw -g window-status-format " #I #W "
setw -g window-status-current-format "  #W "
setw -g window-status-current-fg colour118
setw -g window-status-current-bg default
setw -g window-status-activity-attr underscore,bold

# center the window list
set -g status-justify left

# pane colors
set -g pane-border-fg colour24
set -g pane-border-bg default
set -g pane-active-border-fg colour15
set -g pane-active-border-bg colour15

# command / message line colors
set -g message-fg colour15
set -g message-bg black
set -g message-attr bright

# rebind clear screen with Ctrl-l
bind C-l send-keys 'C-l'

# reload tmux conf
bind r source-file ~/.tmux.conf \; display "Reloaded tmux.conf!"

# setup reattach-to-user-namespace for copy and paste
set-option -g default-command "reattach-to-user-namespace -l $SHELL"

# use vim keybindings in copy mode
setw -g mode-keys vi

setw -g mode-mouse on
setw -g mouse-utf8 on
setw -g mouse-select-pane on
setw -g mouse-select-window on
setw -g mouse-resize-pane on

# setup 'v' to begin selection as in vim
bind -t vi-copy v begin-selection
bind -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

# update default binding of 'enter' to also use copy-pipe
unbind -t vi-copy Enter
bind -t vi-copy enter copy-pipe "reattach-to-user-namespace pbcopy"

# splitting panes
bind | split-window -h
bind - split-window -v

# fast resizing (-r for repeatable)
bind -r h resize-pane -L 5
bind -r j resize-pane -D 5
bind -r k resize-pane -U 5
bind -r l resize-pane -R 5

# tmux navigator with vim (-n allows binding without tmux prefix)
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$' && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$' && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$' && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$' && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$' && tmux send-keys 'C-\\') || tmux select-pane -l"

【问题讨论】:

  • 这些选项也可能是相关的:set-option -g mouse-utf8 onset-option -g mouse-select-pane onset-option -g mouse-select-window on
  • @mMontu:我只是你建议的选项,不幸的是,它仍然没有滚动......setw -g mode-mouse onset -g mouse-utf8 onset -g mouse-select-pane onset -g mouse-select-window on

标签: macos terminal tmux


【解决方案1】:

我发现了问题所在。如果您使用默认的 Terminal.app,则鼠标事件不会传递给终端内运行的应用程序。要解决此问题,您需要安装 MouseTerm,这需要安装 SIMBL。您可以在此处找到所有说明:

https://bitheap.org/mouseterm/

请注意,如果您使用的是 Mac OS X 10.9,当您尝试运行 MouseTerm 的安装脚本时,它会提示该文件已损坏。要解决此问题,只需手动将捆绑文件复制到 SIMBL 插件文件夹并重新启动 Terminal.app 即可工作。您可以在此路径中找到 SIMBL 插件文件夹:

/库/应用程序支持/SIMBL/插件

【讨论】:

  • 2.5.x 航站楼(优胜美地)是否仍然如此?
  • 对于带有 Yosemite 的 Terminal 2.5.x,问题仍然存在。在安装 MouseTerm 和 SIMBL 方面,您必须遵循上述解决方案。我认为它仍然存在的原因是因为 MouseTerm 在 github 上的最新提交是在 2012 年。
  • 对于命令行倾斜,你可以brew install Caskroom/cask/easysimbl,然后git clone https://github.com/brodie/mouseterm.git,然后make,然后make install,然后make test
【解决方案2】:

从 OS X 10.11(Beta)El Capitan 开始,不需要 SIMBL 或 MouseTerm。

我也有同样的问题,但你在 OP 中回答了:

set -g mode-mouse on
setw -g mode-mouse on
set -g terminal-overrides 'xterm*:smcup@:rmcup@'

是 10.11 中使用 Terminal.app 所需的全部 - 注意其他终端仿真器可能仍需要 SIMBL;这是对终端的更新,这意味着似乎不再需要它,而不是因为 OS X 本身正在更新。

【讨论】:

  • @jasonszhao 这个问题和我的答案地址使用的是 Terminal.app,我没有使用 iTerm2,所以无法评论。不过,请注意下面解决 tmux 2.1 的答案。出于兴趣 - 你为什么使用 iTerm2?我从人们那里听到的唯一原因要么现在在终端中提供,要么一直在 tmux 中。
【解决方案3】:

Tmux 2.1 有一些变化

  • 鼠标模式已被重写。现在不再有以下选项:

    • 鼠标调整窗格
    • 鼠标选择窗格
    • 鼠标选择窗口
    • 鼠标模式

    只有一个选项:“鼠标”,它打开鼠标支持 完全。

我猜应该是set -g mouse on

【讨论】:

    【解决方案4】:

    一种无需任何配置即可进行滚动的简单方法是按下 Ctrl-B 然后向上/向下翻页。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-07
      • 1970-01-01
      • 1970-01-01
      • 2011-12-09
      • 2016-01-28
      • 1970-01-01
      • 2011-09-18
      • 2018-05-13
      相关资源
      最近更新 更多