Homebrew and installing homebrew on Mac
Homebrew is an open-source software package manager that makes it easier to install software on macOS (Apple’s operating system) and Linux.
Package Manager’s job is to find and install the right package for your machine. Similarly, Homebrew helps in installing packages on your computer.
Prerequisites
You will need a macOS computer running Catalina or higher with administrative access and an internet connection. While older versions of macOS may work, they are not officially supported and will have limited functionality. Familiarity with vim editor.
Install Brew on Mac
This is the official website of Homebrew : https://brew.sh/
Get sudo access on your machine. Run the following command and enter your password.
Type “exit” and run following set of commands with your user (not with root).
Copy the command below and run on the terminal.
/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
It will run for few minutes and will download the required packages.
Verify the installation your machine by running the below command
brew — version
Run the following command and determine your shell
echo $0
Do not worry if zsh is printed on your screen.
If you’re using ZSH, open~/.zshrc
in your terminal:
vi ~/.zshrc
If you’re using the Bash shell, open ~/.bash_profile
in your terminal:
vi ~/.bash_profile
Paste the following line in your file.
export PATH=/usr/local/bin:$PATH
Save your changes and exit from vim editor.
Close your terminal and open a new terminal for changes to work.
In a new terminal, execute the following command.
brew doctor
Voila! Homebrew is now installed on your Mac.
We can now use Homebrew to install the packages. Tree command will show graphical directory tree.
brew install tree
Run this command to verify the installation of tree
which tree
Occasionally, you’ll want to upgrade an existing package.
brew upgrade tree
To uninstall tree package, use this command
brew uninstall tree
Similarly, you can install, upgrade or remove other packages on your machine.
Homebrew has many packages. Visit the official website and search your favourite packages.