gpt4 book ai didi

key-bindings - tmux:指示是否选择文本的变量?

转载 作者:行者123 更新时间:2023-12-02 00:39:02 25 4
gpt4 key购买 nike

我在 Tmux 的复制模式下使用 vi 键绑定(bind),如果有一个选择,我想让 Esc 清除当前选择,或者如果没有选择则退出复制模式。

bind -T copy-mode-vi Escape if-shell -F '#{selection_active_flag}' \
'send-keys -X clear-selection' \
'send-keys -X cancel'

我希望 Tmux 可以公开一个指示选择状态的变量(我编造了 selection_active_flag 来表达我的意图,它实际上并不存在),类似于 window_zoomed_flag(确实存在)。

有什么办法可以实现吗?

最佳答案

Tmux 2.6 引入了selection_present。如 changelog 中所述,

  • Add selection_present format when in copy mode (allows key bindings that do something different if there is a selection).

这正是我要找的东西,虽然我运行的是 Tmux 2.6,但似乎我有一个过时的手册页,因为它没有提到 selection_present

最终的工作解决方案是:

bind -T copy-mode-vi Escape if-shell -F '#{selection_present}' \
'send-keys -X clear-selection' \
'send-keys -X cancel'

关于key-bindings - tmux:指示是否选择文本的变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47848463/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com