fish:是否可以在自动提示中交换 `right` 和 `Alt + right` 键绑定?
fish: Is it possible to swap `right` and `Alt + right` keybinds in autosuggestion?
在鱼的自我暗示中,right
完全接受建议,Alt + right
通过言语接受。由于我个人更喜欢通过文字提示,所以我想交换这两个键绑定。
我发现我可以使用 bind
命令将键绑定更改为 accept-autosuggestion
,但我找不到交换这两种行为的方法。
是否可以交换这些,如果可以的话,我该如何设置 fish?
来自我的一个旧答案:
No.
Fish's bindings accept the part of the suggestion they move the cursor over - e.g. "forward-word" would move over the next word if that was actually in the commandline, so it accepts the next word of the suggestion.
The exception is "forward-char" (bound to e.g. right-arrow and ctrl-f by default), which accepts the entire suggestion.
澄清一下:forward-char
是 硬编码的 接受整个自动建议,如果它移动到它的第一个字符上。参见 the source。
这将需要一个补丁来钓鱼。
您需要做的就是创建您自己的自定义键绑定,覆盖这些键的默认绑定。创建一个名为 ~/.config/fish/functions/fish_user_key_bindings.fish 的文件,内容类似于:
function fish_user_key_bindings
bind \e\[C forward-bigword
bind \e\e\[C forward-char
end
我说 "similar" 因为您的密钥发送的确切序列可能与我的系统不同(但可能是相同的)。找出您的密钥发送的内容的最简单方法是使用 fish_key_reader
程序。请注意,您只需键入 bind
后跟键名称或它发送的字符序列,但无需执行任何操作,即可发现函数已绑定到键。如果您只键入 bind
,您将看到所有当前有效的绑定。
在鱼的自我暗示中,right
完全接受建议,Alt + right
通过言语接受。由于我个人更喜欢通过文字提示,所以我想交换这两个键绑定。
我发现我可以使用 bind
命令将键绑定更改为 accept-autosuggestion
,但我找不到交换这两种行为的方法。
是否可以交换这些,如果可以的话,我该如何设置 fish?
来自我的一个旧答案:
No.
Fish's bindings accept the part of the suggestion they move the cursor over - e.g. "forward-word" would move over the next word if that was actually in the commandline, so it accepts the next word of the suggestion.
The exception is "forward-char" (bound to e.g. right-arrow and ctrl-f by default), which accepts the entire suggestion.
澄清一下:forward-char
是 硬编码的 接受整个自动建议,如果它移动到它的第一个字符上。参见 the source。
这将需要一个补丁来钓鱼。
您需要做的就是创建您自己的自定义键绑定,覆盖这些键的默认绑定。创建一个名为 ~/.config/fish/functions/fish_user_key_bindings.fish 的文件,内容类似于:
function fish_user_key_bindings
bind \e\[C forward-bigword
bind \e\e\[C forward-char
end
我说 "similar" 因为您的密钥发送的确切序列可能与我的系统不同(但可能是相同的)。找出您的密钥发送的内容的最简单方法是使用 fish_key_reader
程序。请注意,您只需键入 bind
后跟键名称或它发送的字符序列,但无需执行任何操作,即可发现函数已绑定到键。如果您只键入 bind
,您将看到所有当前有效的绑定。