我正在嘗試為魚殼撰寫一個插件,但無法使其正常作業。我在一個名為的檔案中有以下內容functions/codex.fish:
function create_completion
commandline -a test
end
bind \cx create_completion
我使用以下方式安裝了插件fisher:
tom@desktop-20-3 ~/g/b/z/update_insert (main)> fisher install ~/git/codex.fish/
fisher install version 4.3.1
Installing /home/tom/git/codex.fish
/home/tom/.config/fish/functions/codex.fish
Updated 1 plugin/s
但是,當我嘗試使用 Ctrl x 運行該函式時,沒有任何反應。
我究竟做錯了什么?
uj5u.com熱心網友回復:
我在一個名為 functions/codex.fish 的檔案中有以下內容:
有你的問題。魚函式是延遲加載的。首次執行名為“codex”的函式后,將加載名為“codex.fish”的檔案。
因此,這些系結只會在您在該會話中運行一次“codex”后定義(除非有另一個 codex.fish 具有優先權,在這種情況下它們根本不會被定義)。
只需將系結添加到 config.fish 或~/.config/fish/conf.d.
uj5u.com熱心網友回復:
您不需要插件來設定鍵系結。這是一種方法:
- 創建你的函式:
function create_completion
commandline -a test
end
- 將其保存到磁盤:
funcsave create_completion
(這將創建檔案~/.config/fish/functions/create_completion.fish;您也可以手動執行此操作。)
- 運行
funced fish_user_key_bindings并添加您的系結:
function fish_user_key_bindings
bind \cx create_completion
end
現在 control-X 應該執行該功能。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/451684.html
上一篇:什么是參考命令?
下一篇:在Rust中獲取系統命令的輸出
