每个新提示都会触发错误

Error getting triggered on every new prompt

通过 brew 更新了一堆实用程序后,我将 fish shell 从接近 3.0 的版本升级到 3.3.1。现在,每次我在终端中点击 return 时,都会出现一系列迄今为止无害但非常令人分心的错误消息。

$ ls
README.md         node_modules      package.json      static            tsconfig.json
mdsvex.config.cjs package-lock.json src               svelte.config.js  work.eqg
fatal: ambiguous argument '^/dev/null': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: bad revision '^/dev/null'
fatal: Refusing to point HEAD outside of refs/
fatal: No names found, cannot describe anything.
head: ^/dev/null: No such file or directory
$ echo Hi 
Hi 
fatal: ambiguous argument '^/dev/null': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: bad revision '^/dev/null'
fatal: Refusing to point HEAD outside of refs/
fatal: No names found, cannot describe anything.
head: ^/dev/null: No such file or directory
$ 
fatal: ambiguous argument '^/dev/null': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: bad revision '^/dev/null'
fatal: Refusing to point HEAD outside of refs/
fatal: No names found, cannot describe anything.
head: ^/dev/null: No such file or directory
$ 

注意:我已将我的提示简化为 $,因为其中很多提示并不 copy/paste 好。 Fwiw,我正在使用 Bob the Fish,这是屏幕截图:

总之……有什么解决方法吗?

has deprecated the ^ operator for stderr redirection;像

foo ^/dev/null

现在需要这样写:

foo 2>/dev/null

fish-shell/fish-shell issue 8105 提及:

If you encounter these errors in prompt after updating fish shell to 3.3.0:

fatal: not a git repository (or any of the parent directories): .git fatal: Refusing to point HEAD outside of refs/

Then probably you have error redirection with caret (^) in your prompt. Replace it with 2>.

建议:

Doing a full grep -r '\^[/&]' ~/.config/fish/ and fixing everything that comes up (that isn't already quoted)

例如:

I ran that command and found the culprit, it was https://github.com/sjl/z-fish.