tmux.conf中的问题,带有嵌套的if或嵌套的引号

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

我使用共享的配置文件但使用不同的tmux版本SSH到计算机中,所以我尝试使用一个知道版本的.tmux.conf。以下是针对我的tmux 2.6机器的信息。

我的问题似乎是嵌套的if或嵌套的引号。

当只有一个窗口时,以下代码将隐藏状态栏:

if -F '#{==:#{session_windows},1}' 'set -g status off' 'set -g status on'; \
set-hook -g window-linked 'if -F "#{==:#{session_windows},1}" "set -g status off" "set -g status on"'; \
set-hook -g window-unlinked 'if -F "#{==:#{session_windows},1}" "set -g status off" "set -g status on"'; 

但是我的版本保护器在单引号引起来的字符串周围添加了双引号,打破了这个

if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.1" | bc)" = 1 ]' " \
if -F '#{==:#{session_windows},1}' 'set -g status off' 'set -g status on'; \
set-hook -g window-linked 'if -F "#{==:#{session_windows},1}" "set -g status off" "set -g status on"'; \
set-hook -g window-unlinked 'if -F "#{==:#{session_windows},1}" "set -g status off" "set -g status on"'; \
"

tmux启动时没有任何错误,但状态栏未隐藏。

tmux
1个回答
0
投票

您需要将"内的"转义为\"

或将内部命令放在单独的配置文件中,并用source-file加载。

[如果您使用的是更高版本的tmux,则可以使用{}来避免此问题,但是在较旧的tmux版本中,您需要转义引号。

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