配置检测命令是否不存在,建议安装

Tho*_*ard 25 zsh

是否可以将zshshell 配置为显示bash命令不存在时显示的内容,类似于以下内容:

kahless:~$ sysv-rc-conf  
The program 'sysv-rc-conf' is currently not installed.  You can install it by typing:  
sudo apt-get install sysv-rc-conf
Run Code Online (Sandbox Code Playgroud)

而不是 ZSH 提示:

[kahless /home/teward]% sysv-rc-conf  
zsh: command not found: sysv-rc-conf
Run Code Online (Sandbox Code Playgroud)

注意我不想更改提示本身,但我想将结果更改为类似zsh: command not foundbash 的输出The program 'progname' is currently not installed. You can install it by typing:或类似的输出。

ZSH可以做到这一点吗?

Gil*_*il' 25

此功能由 command-not-found 安装找不到命令包裹。Ubuntu 默认安装它,并在 bash 中默认激活它,但在 zsh 中不激活。只需将此行添加到您的~/.zshrc

. /etc/zsh_command_not_found
Run Code Online (Sandbox Code Playgroud)