Tmux 识别窗格是否已缩放并处于活动状态

Glu*_*eon 9 tmux

我使用 tmux 1.8,所以我内置了CTRL+b+z缩放活动窗格的功能。
问题是缩放窗格看起来与一个普通窗格相同,所以有时我会忘记窗格是否被缩放。有没有办法添加我当前处于缩放模式的指示?

同样的问题是水平分割的窗格。很难记住左侧的边框是否对应于活动的上部窗格,反之亦然。我可以让它更明显吗?如果可能的话,也许可以添加水平边框?

ari*_*ane 14

在缩放功能window_flag的同时Z,添加了同名,所以这个标志应该出现在窗口标题旁边的状态行中(你在评论中提到你使用了一些插件/tmux 自定义)。


在任何情况下,您都可以使用以下list-panes命令和formats功能查询 tmux :

 tmux list-panes -F '#F'
Run Code Online (Sandbox Code Playgroud)

打印出当前活动窗格的所有窗口标志。如果Z在标志中,则当前窗格被缩放。因此,命令

 tmux list-panes -F '#F' | grep -q Z
Run Code Online (Sandbox Code Playgroud)

0如果当前窗格被缩放,将返回,如果不是,则返回错误1。这应该允许您将此指示器添加到您的自定义状态行。


来自man tmux:

 FORMATS

 Certain commands accept the -F flag with a format argument.  This is a
 string which controls the output format of the command.  Replacement
 variables are enclosed in ‘#{’ and ‘}’, for example ‘#{session_name}’.
 The possible variables are listed in the table below, or the name of a
 tmux option may be used for an option's value.  Some variables have a
 shorter alias such as ‘#S’, and ‘##’ is replaced by a single ‘#’.

 [...]

 Variable name          Alias    Replaced with
 [...]
 window_flags           #F       Window flags
Run Code Online (Sandbox Code Playgroud)

查看源代码(window.c,第 639f 行)显示完整的标志列表是:

 #:  window activity flag
 !:  window bell flag
 ~:  window silence flag
 *:  current window flag
 -:  last window flag
 Z:  window zoomed flag
 ' ' (a space):  no flags at all.
Run Code Online (Sandbox Code Playgroud)