You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
This project reproduces Ubuntu’scommand-not-found for Homebrew users onmacOS.
On Ubuntu, when you try to use a command that doesn’t exist locally but isavailable through a package, Bash will suggest you a command to install it.Using this script, you can replicate this feature on macOS:
# on Ubuntu$ whenThe program'when' is currently not installed. You can install it by typing:sudo apt-get install when# on macOS with Homebrew$ whenThe program'when' is currently not installed. You can install it by typing: brew install when
Over 5000 formulae are supported, representing more than 17000 different commands(100% of the main Homebrew repo).
Install
First, tap this repository:
brew tap homebrew/command-not-found
Bash and Zsh: Add the following line to your~/.bash_profile (bash) or~/.zshrc (zsh):
When you tap the repo you’ll get two morebrew commands:brew which-formulaandbrew which-update. The first one uses a database file which gives you theformula you have to install in order to get a specific command. The file isgenerated by the second command by crawling all installed formulae andcollecting their binaries. Having this as a tap means you get an up-to-datebinaries database each time you runbrew update.
Thehandler.sh script defines acommand_not_found_handle function which isused by Bash when you try a command that doesn’t exist. The function callsbrew which-formula on your command, and if it finds a match it’ll print it toyou. If not, you’ll get an error as expected.
About
🔍 Ubuntu’s command-not-found equivalent for Homebrew on macOS