如何创建在 Fish 中插入文本的键绑定 shell

How to create a key binding that inserts text in the Fish shell

我想通过将键绑定到文本来节省在 Fish shell 中的输入。当我按下该键时,文本应插入 shell。效果应该与键入该文本相同。

问题之一是文本不应该被执行,只是被插入。我最接近的是这个实验,当我按 Alt+G 时插入文本 "whoami":

bind \eg "echo -n whoami"

但是,当我回车的时候,命令并没有执行,所以效果和直接在shell中输入文字是不一样的。

您想修改 命令行 ,顺便说一句,这可以通过 commandline 内置函数实现。

 bind \eg "commandline -i whoami"