How to install Homebrew (macOS)

~Editor

TL;DR

install Xcode-tools, download and execute installation script, add homebrew path to shell configuration, source the shell configuration file.

First, paste the code below to install Xcode Command Line Tool

xcode-select --install

Download a script to install Homebrew

curl -fsSL -o install.sh https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh

use the command below to execute the installation script

/bin/bash install.sh

Execute the command below to configure the Homebrew executable path in your shell configuration

nano ~/.zshrc

execute nano ~/.bash_rc or ~/.bash_profile instead, if you're using bash (for old ones)

Paste the following line to .zshrc (or the file youre currently edit)

export PATH=/usr/local/bin:$PATH

this will prepend the Homebrew executable path to the $PATH variable

Run the following command to make the environment variable persist

source ~/.zshrc

(or source ~/.bash_profile). The homebrew command will now be available everywhere even after your device is restarted