Zsh 想要自动更正命令,在它之前有一个 _ [英] Zsh wants to autocorrect a command, with an _ before it
问题描述
我最近才开始使用 Zsh 来为我的 Git 状态等在 shell 提示中提供一些集成支持.
I just started using Zsh lately for some of the integrated support in the shell prompt for my Git status etc.
当我输入时:
ruby -v
为了确认我正在运行的 ruby 版本,Zsh 询问我是否要将命令更改为 _ruby.在提示符下说不"并且命令按预期完成后,在确认我的命令正确后,我继续在提示符下收到问题.
to confirm the version of ruby I'm running, Zsh asks if I want to change the command to _ruby. Well after saying no at the prompt and the command completing as expected I continue to get the question at the prompt after confirming my command is correct.
我假设有一个完成文件或类似的东西.
I'm assuming there is a completion file or something of the sort.
谢谢
更新:
外壳不再尝试完成 _ruby,它在关闭外壳几次后停止响应.
The shell is no longer trying to complete _ruby, it stopped responding after closing the shell a few times some how.
我多次尝试清理文件,但有一个opts"变量长达 50 行或更多行,并且所有行都运行在一起,有些行超过 150 个字符.如果你还想看的话,我可以给你发个附件.对于这篇乱七八糟的帖子,我深表歉意.
I tried to clean the file up several times but there is a "opts" variable that is 50 or more lines long and the lines are all ran together, some lines more than 150 characters. Maybe I could email an attachment to you if you still want to see it. I sincerely apologize for the messy post.
推荐答案
这是命令自动更正,由 correct
选项激活.它与完成无关.您看到 _ruby
是因为 zsh 认为没有 ruby
命令并且它提供 _ruby
作为最接近的现有匹配.
This is command autocorrection, activated by the correct
option. It has nothing to do with completion. You're seeing _ruby
because zsh thinks there is no ruby
command and it offers _ruby
as the nearest existing match.
如果你刚刚安装了 ruby
,可能 zsh
之前已经记住了可用命令的列表,它不会总是尝试查看命令已经出现在两者之间.在这种情况下,运行 hash -rf
.以后的 zsh 会话不会有这个问题,因为 ruby
命令在它们开始时已经存在.
If you've just installed ruby
, it's possible that zsh
has memorized the list of available command earlier, and it won't always try to see if the command has appeared in between. In that case, run hash -rf
. Future zsh sessions won't have this problem since the ruby
command already existed when they started.
有时,当您更改 PATH
时,zsh 会忘记一些散列命令.选项 hash_listall
有助于解决这个问题.如上,如果您可以使用 hash -rf
强制 zsh 刷新其命令缓存.
Sometimes, when you change your PATH
, zsh forgets some hashed commands. The option hash_listall
helps against this. As above, if you can force zsh to refresh its command cache with hash -rf
.
这篇关于Zsh 想要自动更正命令,在它之前有一个 _的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!