Tmux密钥绑定问题


8

我已经从使用屏幕切换到使用tmux。我有一个tmux配置,它使用屏幕的Ctrl+ a序列,而不是tmux的默认Ctrl+ b

但是,我发现的一个问题是,如果我按ctrl-a然后在不释放ctrl键的情况下在上一个屏幕中按p或在下一个屏幕中按n,则tmux会忽略键序列。如果按Ctrl+ a,释放Ctrl,然后按np,则可以正常工作。

有什么想法可能有问题吗?我的配置如下:

# $Id: t-williams.conf,v 1.1 2009/11/02 18:59:28 nicm Exp $
#
# ~/.tmux.conf - tmux terminal multiplexer config
# Thayer Williams (http://cinderwick.ca)
# "Feel free to do whatever you like with it."

# set prefix key to ctrl+a
unbind C-b
set -g prefix C-a

# send the prefix to client inside window (ala nested sessions)
bind-key a send-prefix

# toggle last window like screen
bind-key C-a last-window

# confirm before killing a window or the server
bind-key k confirm kill-window
bind-key K confirm kill-server

# toggle statusbar
bind-key b set-option status

# ctrl+left/right cycles thru windows
bind-key -n C-right next
bind-key -n C-left prev

# open a man page in new window
bind / command-prompt "split-window 'exec man %%'"

# switch split window keys
unbind %
bind | split-window -h
bind - split-window -v

# quick view of processes
bind '~' split-window "exec htop"

# scrollback buffer n lines
set -g history-limit 10000

# listen for activity on all windows
#set -g bell-action any
setw -g monitor-activity off
set -g visual-activity off

# on-screen time for display-panes in ms
set -g display-panes-time 2000

# start window indexing at one instead of zero
set -g base-index 1

# enable wm window titles
set -g set-titles on

# Automatically set window title
setw -g automatic-rename

# statusbar --------------------------------------------------------------

set -g display-time 2000

# default statusbar colors
set -g status-fg white
set -g status-bg cyan
set -g status-attr default

# default window title colors
set-window-option -g window-status-fg black
set-window-option -g window-status-bg cyan
set-window-option -g window-status-attr default

# active window title colors
set-window-option -g window-status-current-fg white
set-window-option -g window-status-current-bg black
set-window-option -g window-status-current-attr bright

# command/message line colors
set -g message-fg blue
set -g message-bg white
set -g message-attr dim

# center align the window list
set -g status-justify centre

# show some useful 
set -g status-left "[#[fg=black]#H#(uptime | cut -d ',' -f 3- | sed -e 's/ load average: //' | sed -e 's/  / /g')#[default]]"
set -g status-left-length 50
set -g status-right "[#[fg=black]%a %Y-%m-%d %H:%M#[default]]"
set -g status-right-length 50

set -g default-terminal "screen"

Answers:


7

我找到了模仿屏幕下原始行为的解决方案(仅包括配置的相关部分,其余仅是窗口装饰):

# set prefix key to ctrl+a until I have time to adapt
unbind C-b
set -g prefix C-a

# send the prefix to client inside window (ala nested sessions)
bind-key a send-prefix

# toggle last window like screen
bind-key C-a last-window

# navigate through windows like screen
bind-key C-a-n next
bind-key C-a-p prev

解决方案是直接将关键序列链接在一​​起。我没有意识到您实际上可以执行此操作,但是它可以完美运行,并且我仍然可以保留send-prefix选项(我担心这是问题的一部分)。


我认为您可以标记自己的答案作为解决方案,这将对其他人有所帮助。
gitaarik 2014年

使用默认的键盘绑定后,我的设置会有所不同:bind-key C-nbind-key C-p。它允许我继续按Ctrl。
SergioAraujo

2

Tmux会将ctrl键按下时执行的任何按键都视为C形式。您可以简单地添加bind C-p prevbind C-n next获得相同的效果。


谢谢,亚历克斯,这使我步入正轨。不过,我不想做ctrl-p和ctrl-n;我仍然管理一些没有tmux的机器,并且我仍会不时使用屏幕,因此我一直在寻找一些与屏幕的原始行为更接近的东西。但是您的评论让我继续思考如何使其正确无误。
Morgan Blackthorne
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.