problem
In
the process of using zsh on ubuntu 20.04 , it is found that if the command entered does not exist, it will only prompt
command 'tmux' not found
When using bash, the prompt will be more complete,
Command 'tmux' not found, but can be installed with:
sudo snap install tmux # version 2.3, or
sudo apt install tmux # version 3.0a-2ubuntu0.1
See 'snap info tmux' for additional versions.
No hint is very unfriendly to me as a novice.
- First, it is impossible to accurately and quickly determine the source of the problem. It may be a configuration problem of environment variables, it may be that the corresponding software is not installed, or it may be a problem of the software itself, which is more troublesome to troubleshoot.
- The second is that for packages that are not commonly used, the package name cannot be accurately remembered, which may cause installation errors or the package cannot be found
. How to solve this problem for more convenient use?
Solutions
One, traceability
Since bash can, then take a look at is how to achieve bash
.bashrc found /etc/bash.bashrc ==>
View bash.bashrc ==>
# if the command-not-found package is installed, use it
2. README
https://packages.ubuntu.com/focal/command-not-found
find the source package, unzip, README
#Command-not-found
This application implements the command-not-found spec at:
https://wiki.ubuntu.com/CommandNotFoundMagic
If you want automatic prompts to install the package, set
COMMAND_NOT_FOUND_INSTALL_PROMPT in your environment.
To use it in bash, please add the following line to your .bashrc file:
. /etc/bash_command_not_found
To use it in zsh, please add the following line to your .zshrc file:
. /etc/zsh_command_not_found
Note that it overrides the preexec and precmd functions, in case you have
defined your own.
Oh I got it,
To use it in zsh, please add the following line to your .zshrc file:
. /etc/zsh_command_not_found
After adding, the prompt message is displayed perfectly