如何像在 Ubuntu bash 中一样启用 zsh 软件包建议?

El *_*nor 10 command-line zsh auto-completion

我正在慢慢地从 bash 过渡到 zsh,并且几乎喜欢它的每个部分,但有两件事我真的很想念。其中之一是快照完成,请参阅此处: Enable snap TAB-completion for zsh

另一种是你在 Ubuntu 终端中输入命令,而不是“哦不!” 找不到命令!' 马上,你会得到这样的结果:

user@computer:~$ inkscape

Command 'inkscape' not found, but can be installed with:

sudo snap install inkscape  # version 0.92.4, or
sudo apt  install inkscape  # version 0.92.4-5ubuntu5

See 'snap info inkscape' for additional versions.
Run Code Online (Sandbox Code Playgroud)

有什么方法可以在 zsh 中启用此功能吗?我真的不想再为了使用它和快速自动补全而切换回 bash。

谢谢!

小智 13

对于apt 包建议,我们可以通过以下方式进行:

$ sudo apt install command-not-found
$ echo "source /etc/zsh_command_not_found" >> ~/.zshrc
$ exec zsh
Run Code Online (Sandbox Code Playgroud)


小智 7

如果您使用oh-my-zsh,它带有名为 的插件command-not-found,您可以通过编辑 ~/.zshrc 来启用它,添加command-not-found到插件列表中。

例如插件=(命令未找到)