首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >向上箭头不正常工作

向上箭头不正常工作
EN

Unix & Linux用户
提问于 2022-04-18 17:29:28
回答 1查看 1.9K关注 0票数 1

系统:

  • ubuntu 20.04
  • Linux 5.13.0-39-泛型
  • tmux 3.0a

问题:

  • 当使用tmux时,任何直接连接到我的主机上的ssh会话,我都不能再使用向上箭头,它不会在远程主机上被重新编码。如果在tmux之外建立ssh会话,则不会发生此问题。另外,如果我将ssh转到另一个主机,那么对于我想要使用箭头的主机,则不会发生此问题。
  • 在使用tmux时,而不是在ssh会话中,向上箭头可以工作。但是,我不能再使用tmux-action-组合体+ Ctrl+up来调整会话的大小。这在tmux-action-组合体+ Alt+up中不会发生,它将按预期调整屏幕的大小。

注意:所有其他箭头键和tmux组合键工作良好,没有任何问题.

我有种感觉,这需要处理从旧版本的tmux导入的键绑定。

配置:这是我为.tmux.conf使用的配置

代码语言:javascript
运行
复制
set-environment -g TMUX_PLUGIN_MANAGER_PATH '~/.tmux/plugins/'

# This session is allow Mobaxterm sessions to scroll without having to hold SHIFT after reattaching
#set -g terminal-overrides 'xterm*:smcup@:rmcup@'

# Set default TERM type
set -g default-terminal "screen-256color"
set-option -ga terminal-overrides ",*256col*:Tc"

# Enable mouse control
set -g mouse on

unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

#set -g status off
set-option -g status-position top
set -sg escape-time 0
set -g focus-events on

# enable vim bindings for copy mode
set-window-option -g mode-keys vi

# copy to system clipboard
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard"
bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard"
bind -T copy-mode-vi C-j send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard"


bind-key -n C-h select-pane -L
bind-key -n C-j select-pane -D
bind-key -n C-k select-pane -U
bind-key -n C-l select-pane -R

#Copy and paste from terminal (non-vim)
bind-key    -T copy-mode    C-w               send-keys -X copy-pipe-and-cancel "xclip -i -selection clipboard > /dev/null 2>&1"
bind-key    -T copy-mode    MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -i -selection clipboard > /dev/null 2>&1"
bind-key    -T copy-mode    M-w               send-keys -X copy-pipe-and-cancel "xclip -i -selection clipboard > /dev/null 2>&1"
bind-key    -T copy-mode-vi C-j               send-keys -X copy-pipe-and-cancel "xclip -i -selection clipboard > /dev/null 2>&1"
bind-key    -T copy-mode-vi Enter             send-keys -X copy-pipe-and-cancel "xclip -i -selection clipboard > /dev/null 2>&1"
bind-key    -T copy-mode-vi y                 send-keys -X copy-pipe-and-cancel "xclip -i -selection clipboard > /dev/null 2>&1"
bind-key    -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -i -selection clipboard > /dev/null 2>&1"


bind p paste-buffer
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle

unbind '"'
unbind %
bind n split-window -v -c '#{pane_current_path}'
bind m split-window -h -c '#{pane_current_path}'
bind c new-window -c '#{pane_current_path}'
bind r command-prompt "respawn-pane -k" \

#tmux sync all screens in windows
bind -n C-y setw synchronize-panes


###########
# Plugins #
###########



#Install Plugins
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

#Plugin: tmux-resurrect
set -g @resurrect-processes ':all:'
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-capture-pane-contents 'on'

#Plugin: tmux-continuum
set -g @continuum-save-interval '15'
set -g @continuum-restore 'on'
set -g status-right 'Continuum status: #{continuum_status}'

#Initalize TMUX plugin manager
run '~/.tmux/plugins/tpm/tpm'

下面是tmux-action-组合体+ ?中出现的内容:

代码语言:javascript
运行
复制
bind-key    -T copy-mode    Up                    send-keys -X cursor-up
bind-key    -T copy-mode    M-Up                  send-keys -X halfpage-up
bind-key    -T copy-mode    C-Up                  send-keys -X scroll-up

我在这里错过了什么?为什么tmux不允许我在ssh会话中使用Up,或者使用tmux-action-组合体+ Up来调整窗格的大小?

EN

回答 1

Unix & Linux用户

发布于 2022-04-23 17:33:15

弄明白了。

我上面定义的两个问题需要重新定义。实际问题如下:

  1. 在与JUNIPER主机的ssh会话中,向上箭头键不再被识别。
  2. 无法识别Ctrl+Up密钥组合。

问题1的

解决方案:

原因: Juniper主机没有识别tmux窗格正确使用的$TERM值,也没有遵守向上或向下的箭头键。

解决方案:我删除了已有的两个术语设置,并将该术语设置为xterm-256color (Ubuntu实例的默认设置)。这就解决了问题:

代码语言:javascript
运行
复制
# Set default TERM type
set -g default-terminal "xterm-256color"
# set -g default-terminal "screen-256color"
# set-option -ga terminal-overrides ",*256col*:Tc"

问题2的

解决方案:

原因:当我直接从Ubuntu框中使用tmux时,没有发生这个问题。这个问题确实发生在我从我的电脑上进行VNC时。经过更多的故障排除后,我发现这个问题是由我的主机上的另一个应用程序引起的,我使用我的VNC客户端是因为干扰了"Ctrl+Up“密钥组合,这意味着密钥组合体从未通过VNC会话发送。

解决方案:删除干扰应用程序上的组合键后,通过VNC客户端正确发送组合键"Ctrl+Up“,并再次使用tmux。

票数 0
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/699479

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档