如何使用鼠标滚动tmux?

 嗯明天娶你 发布于 2023-01-11 18:53

我在带有Apple魔术鼠标的Terminal.app中使用Mac OS X 1.9.3上的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"

RantriX.. 14

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

https://bitheap.org/mouseterm/

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

/ Library/Application Support/SIMBL/Plugins

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

    https://bitheap.org/mouseterm/

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

    / Library/Application Support/SIMBL/Plugins

    2023-01-11 18:55 回答
  • Tmux 2.1有一些变化

    鼠标模式已被重写.现在不再有选择:

    鼠标调整大小窗格

    鼠标选择窗格

    鼠标选择窗口

    模式小鼠

    相反,只有一个选项:'鼠标'完全打开鼠标支持.

    我想那就是 set -g mouse on

    2023-01-11 18:56 回答
  • 从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本身更新.

    2023-01-11 18:56 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有