2017-08-06 15 views
2

魚文檔說,你可以使用語法`bind`不運行用戶定義的函數

bind <char> cmd1 cmd2 ...

包括https://fishshell.com/docs/current/commands.html#bind列出了一些speciall命令運行命令的列表。

寫有按鍵綁定一個插件,

我加

bind '&' `backward-delete-char` on_ampersand

fish_user_key_bindings.fish,但它沒有導致行爲 - 的on_ampersand函數不叫,也不是backward_delete_char。沒有on_ampersand,它工作。

文檔沒有提供任何有關此行爲可能發生的原因。

回答

2

這是魚的錯誤 - 您不能將輸入緩衝區編輯命令與您自己的命令組合在一起。見https://github.com/fish-shell/fish-shell/issues/3683

解決方法是使用commandline -f [function]語法在用戶定義的函數訪問專門提供這些功能fish_user_key_bindings

function on_ampersand 
    commandline -f backward-delete-char # or whatever 
    [your code] 
end 
+0

,因爲它是按預期不是一個真正的錯誤。但是這種行爲沒有充分的文件記錄。歡迎修補程序來改進文檔。 –