tmux 配置中复杂 commands/bindings 的分隔符

Delimiter for complex commands/bindings in tmux config

我正在寻找一种在我的 tmux 配置中使 the following line 正确的方法:

bind -n S-F12 unbind -n S-Left \; unbind -n S-Right \; unbind -n S-Down \; unbind -n S-Up \; unbind -n M-Left \; unbind -n M-Right \; unbind -n M-Down \; unbind -n M-Up \; bind -n S-F12 source "$HOME/.tmux.conf"  \; display-message "Tmux Vim Mode: DISABLED" \; display-message "Tmux Vim Mode: Enabled"

重点是在执行 S-F12 时切换一些绑定并在成功时打印消息。问题是消息 "Tmux Vim Mode: DISABLED" 从未打印出来,可能是由于绑定的定界符不明确。

有没有办法让它工作?

ps:我不想创建另一个 tmux 配置文件并使用 source

您可以尝试的是

bind -n S-F12 unbind -n S-Left \; \
 unbind -n S-Right \; \
 unbind -n S-Down \; \
 unbind -n S-Up \; \
 unbind -n M-Left \; \
 unbind -n M-Right \; \
 unbind -n M-Down \; \
 unbind -n M-Up \; \
 bind -n S-F12 run-shell 'tmux source "$HOME/.tmux.conf"  \; \
                          display-message "Tmux Vim Mode: Enabled"'  \; \
 display-message "Tmux Vim Mode: DISABLED"

确保 \ 是使用这种续行时该行的最后一个字符。键入 Shift-F12 将取消绑定,并重新绑定到 run-shell 可以处理 sourcedisplay-message 作为内部的单个字符串''。我已将消息反转为我认为您想要的,但我可能错了。