设置并从功能执行命令
如何编写在字符串中执行命令并在历史记录中显示命令的鱼功能?
function qh --description 'Use peco to query command history'
if test (count $argv) = 0
set peco_flags --layout=bottom-up
else
set peco_flags --layout=bottom-up --query "$argv"
end
history | peco $peco_flags | read cmd
if test $cmd
commandline $cmd
else
commandline ''
end
end
这不起作用...
How can I write a fish function that executes a command in a string and make it appear in the history?
function qh --description 'Use peco to query command history'
if test (count $argv) = 0
set peco_flags --layout=bottom-up
else
set peco_flags --layout=bottom-up --query "$argv"
end
history | peco $peco_flags | read cmd
if test $cmd
commandline $cmd
else
commandline ''
end
end
This does not work...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以创建一个键绑定,以设置命令行,然后执行它。然后,该命令将出现在历史中。示例:
现在ALT-Q将将命令行设置为
今天的Echo是星期日
并执行它。它出现在历史上。除此之外,还有 abbreviations 可以用文本代替代币;但是文本只是静态的(例如
gco-> git Checkout
)。尚无任意鱼类功能(例如作为壳脚本的一部分运行)附加到历史记录,只有从中删除并读取它。
It is possible to create a key binding which sets the command line and then executes it; that command will then appear in history. Example:
now alt-q will set the commandline to
echo Today is Sunday
and execute it; it appears in history.Beyond that there are also abbreviations which allow replacing tokens with text; but the text is just static (e.g.
gco -> git checkout
).There is as yet no way for an arbitrary fish function (e.g. run as part of a shell script) to append to history, only delete and read from it.