如何判断 Tmux 中的哪个窗格获得焦点?

问题描述 投票:0回答:7

我开始使用 tmux(我正在考虑从屏幕切换),但是当我将一个窗口分成多个窗格时,我很难判断哪个窗格是焦点。是否有配置自定义或可以更明确地突出显示焦点窗格的东西?

tmux
7个回答
109
投票

相关设置如下:

pane-active-border-style fg=colour,bg=colour
    Set the pane border colour for the currently active pane.

所以,尝试将这样的内容添加到您的

~/.tmux.conf

set-option -g pane-active-border-style fg=blue

这将在活动窗格周围设置蓝色边框。

pane-active-border-style bg=colour
选项也可用于更明显的解决方案。


41
投票

正如另一篇文章中的回答,现在可以在 tmux 2.1 中设置各个窗格的颜色。可以使用:

set -g window-style 'fg=colour247,bg=colour236'
set -g window-active-style 'fg=colour250,bg=black'

~/.tmux.conf
文件中显示活动/非活动窗格之间的差异。

使用 Vim 如果您发现它不适用于 Vim 窗格,则可能与您使用的配色方案有关。首先,尝试其他配色方案,例如

pablo
。欲了解更多详情,请参阅其他帖子


15
投票

自定义

status-left
并使用
#P
字符对,即窗格编号。您可能想要在状态栏中包含的不仅仅是窗格编号,但以下是您要添加到
~/.tmux.conf
中仅用于窗格编号的行的示例:

set-option -g status-left '#P'

有关更多字符对,请参阅 tmux 手册页:http://manpages.ubuntu.com/manpages/precise/en/man1/tmux.1.html


7
投票

对我有用的一个解决方案是在窗格切换热键的末尾添加一个显示窗格。这将显示所有窗格编号,当前窗格采用不同的颜色。您还可以使用

<escape_key> + q
显示窗格编号。

我使用

alt+h/j/k/l
在窗格之间切换,并使用以下绑定。

bind -n M-j select-pane -D \; display-pane                                                                                                                                                                                                               
bind -n M-k select-pane -U \; display-pane                                                                                                                                                                                                               
bind -n M-h select-pane -L \; display-pane                                                                                                                                                                                                               
bind -n M-l select-pane -R \; display-pane  

0
投票

我希望活动窗格的边框比其他窗格更亮, 所以我选择了这个(适用于 tmux 1.8 w/CentOS 7):

~/.tmux.conf 片段

# rgb hex codes from https://www.rapidtables.com/web/color/RGB_Color.html
set-option -g pane-active-border-fg '#33FF33' # brighter green
set-option -g pane-border-fg '#006600' # darker green

tmux 手册页说十六进制 RGB 颜色将被近似,我发现十六进制代码比记住“colour47”(颜色 0-255 之外)更容易理解,是一种浅绿色(如 tmux 是如何工作的)调色板有用吗?)。

tmux 手册页摘录:

message-bg colour
    Set status line message background colour, ...etc...
    or a hexadecimal RGB string such as ‘#ffffff’, which chooses the closest
    match from the default 256-colour set.

0
投票

对于 tmux 3,我可以在 .tmux.conf 中设置以下内容以获得微妙的边框指示器:

set-option -g pane-active-border-style bg=yellow

0
投票

[ctrl+b, z] 放大聚焦窗格,[ctrl+b, z] 缩小。这样您就会弄清楚哪个窗格是焦点。只是为了分享。

© www.soinside.com 2019 - 2024. All rights reserved.