2010-11-12 14:02:16 +0000 2010-11-12 14:02:16 +0000
271
271
Advertisement

在tmux中用鼠标滚动shell输出。

Advertisement

鼠标滚动在tmux中不能工作,当我在没有tmux的情况下运行shell(在Gnome终端中)时,它的工作方式。似乎tmux发送鼠标滚动事件,就像我按了上/下键一样。但我希望它能滚动shell的_输出历史。有什么方法可以让tmux这样工作吗?

注:我知道如何用键盘滚动(感谢另一个问题这里)。

我试过在两个版本的tmux中用鼠标滚动:

Advertisement
Advertisement

答案 (10)

264
264
264
2010-12-01 18:48:45 +0000

要在输出的历史中滚动,你可以使用^b+[,然后你可以使用M+V向上翻页,^V向下翻页。我不知道你是否可以使用真正的PgUp和PgDown。我的终端没有将这些键发送到TMUX。相反,它自己滚动,而不是tmux的历史。

要退出复制模式,请按ESC

要在此模式下使用鼠标(称为复制模式),请按^b + :并输入如下。

setw -g mouse on

注意:在tmux < 2.1中,这个选项被命名为mode-mouse,而不是mouse

现在当你切换到复制模式时,你可以用鼠标滚动它。如果你想的话,你可以把这个命令放在 ~/.tmux.conf 中,这样每次你运行 tmux 时它都会加载。

Update: 从tmux 1.5开始,这个选项可以让使用滚轮自动切换到复制模式,并回滚tmux的回滚缓冲区。不再需要先按Ctrl-B+[。向后滚动到提示也会自动结束复制模式。

127
127
127
2015-10-19 11:02:01 +0000

Tmux 2.1

有一些变化 - 鼠标模式已被重写。现在不再有选项了。

现在是

set -g mouse on
# to enable mouse scroll, see https://github.com/tmux/tmux/issues/145#issuecomment-150736967
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"
```。
64
Advertisement
64
64
2011-11-15 20:05:50 +0000
Advertisement

目前的tmux(1.5)版本可以让你简单地设置模式-鼠标选项,并允许你用鼠标滚轮滚动。

mode-mouse [on | off]
                 Mouse state in modes. If on, the mouse may be used to
                 enter copy mode and copy a selection by dragging, to
                 enter copy mode and scroll with the mouse wheel, or to
                 select an option in choice mode.

在我的.tmux.conf中。

set-window-option -g mode-mouse on
``` 在我的.tmux.conf中: 

0x1&
59
59
59
2012-10-24 16:55:07 +0000

在你的.tmux.conf中试试这个

# Make mouse useful in copy mode
setw -g mode-mouse on

# Allow mouse to select which pane to use
set -g mouse-select-pane on

# Allow xterm titles in terminal window, terminal scrolling with scrollbar, and setting overrides of C-Up, C-Down, C-Left, C-Right
set -g terminal-overrides "xterm*:XT:smcup@:rmcup@:kUP5=\eOA:kDN5=\eOB:kLFT5=\eOD:kRIT5=\eOC"

# Scroll History
set -g history-limit 30000

# Set ability to capture on start and restore on exit window data when running an application
setw -g alternate-screen on

# Lower escape timing from 500ms to 50ms for quicker response to scroll-buffer access.
set -s escape-time 50

取自 http://brainscraps.wikia.com/wiki/Extreme多任务处理与tmuxandPuTTY

16
Advertisement
16
16
2011-06-22 17:10:05 +0000
Advertisement

有人(从我丢失的一个来源)建议在~.tmux.conf中添加以下内容。

set -g terminal-overrides 'xterm*:smcup@:rmcup@'

我不知道它是如何工作的,也不知道它是做什么的,但现在我可以在tmux会话中用鼠标滚轮滚动,而不必进入tmux的复制模式;我只需滚动滚轮,然后就可以了。请注意,我使用的是terminal.app,但我记得OP给出的答案是专门针对gnome-terminal的使用。

5
5
5
2015-12-15 23:44:29 +0000

tmux 2.1引入了新的鼠标绑定。

我今天刚刚写了这些绑定。当不在Vim中时,它可以将鼠标滚轮与箭头无缝绑定,因为Vim能够解释原始的鼠标滚轮代码(用于诸如根据你的鼠标在哪个窗口上选择为你滚动哪个Vim窗口)。

这意味着我们终于可以只用鼠标来查看多个man页面和其他任何接受方向键的东西了。你可以根据需要扩展和连锁if逻辑,为你的应用实现更多的逻辑。

bind -n WheelUpPane if "[[#{pane_current_command} =~ vim]]" "select-pane -t = ; send-keys -M" "select-pane -t = ; send-keys Up"
bind -n WheelDownPane if "[[#{pane_current_command} =~ vim]]" "select-pane -t = ; send-keys -M" "select-pane -t = ; send-keys Down"

有了这个新的滚轮绑定功能,就可以为鼠标滚轮编写脚本,以执行任何你喜欢的上下文敏感行为。

5
Advertisement
5
5
2019-04-23 15:29:55 +0000
Advertisement

如果你已经在tmux会话中,你可以运行命令

set mouse on

提醒:运行命令时,使用你的前缀,然后使用:

3
3
3
2010-12-07 07:03:31 +0000

Gnome-terminal做了一些巧妙的技巧,在限制 “通常 "滚动的条件下,将鼠标滚动事件翻译成上下方向键。例如,当你使用less查看一些文本时(这种情况特别发生在你阅读一个人的时候),你可以使用jk和方向键滚动内容。但_也是,使用gnome-terminal,你可以用鼠标滚动来实现,这要感谢提到的技巧。

所以我猜tmux会像less一样对终端进行一些 "捕捉”–而gnome-terminal中的相同机制也开始发挥作用:鼠标滚动转化为按上/下方向键。

你可以在配置文件设置中关闭这个功能,并在任何情况下获得常规滚动。只需取消 “滚动 "选项卡中最后一个复选框的标记。

.

1
Advertisement
1
1
2018-01-02 23:48:52 +0000
Advertisement

https://github.com/NHDaly/tmux-better-mouse-mode

可配置且功能丰富的鼠标控制实现,适用于较新的tmuxes,强烈推荐。

你可能也想使用

set -g @emulate-scroll-for-no-mouse-alternate-buffer "on"

0
0
0
2018-02-12 23:02:10 +0000

你可以结合其他答案中的绑定思想,得到一个非常令人满意的滚动行为:在vim中工作,在终端中自动切换到复制模式,到达底部时退出,仍然允许你在man、less和journalctl中使用鼠标滚轮。

我的代码。

bind -n WheelUpPane if -t = "test $(echo #{pane_current_command} |grep -e 'man' -e 'less' -e 'journalctl')" "select-pane -t = ; send-keys Up Up Up Up" "if-shell -F -t = '#{?mouse_any_flag,1,#{pane_in_mode}}' 'send-keys -M' 'select-pane -t = ; copy-mode -e; send-keys -M'"
bind -n WheelDownPane if -t = "test $(echo #{pane_current_command} |grep -e 'man' -e 'less' -e 'journalctl')" "select-pane -t = ; send-keys Down Down Down Down" "if-shell -F -t = '#{?mouse_any_flag,1,#{pane_in_mode}}' 'send-keys -M' 'select-pane -t = ; copy-mode -e; send-keys -M'"

你可以在grep -e ‘man'部分添加其他需要方向键滚动的命令

我添加了多次发送键,所以在鼠标滚轮上打一个勾就能一次滚动4行。

Advertisement

相关问题

6
10
12
11
2
Advertisement