Skip to content
shellmap

brewmacOS (and Linux) package manager via Homebrew across all 5 shells

Equivalents in every shell

Bashunix
brew install ripgrep

Homebrew installs to `/opt/homebrew` on Apple Silicon, `/usr/local` on Intel Mac, `/home/linuxbrew/.linuxbrew` on Linux. Core verbs: `brew install <formula>` (CLI tools — installs to `bin/`); `brew install --cask <cask>` (GUI apps on macOS — `.app` bundles into `/Applications/`); `brew uninstall <formula>`; `brew update` (refresh formula definitions); `brew upgrade [<formula>]` (upgrade specific or all); `brew list` (installed); `brew search <q>` (find formulas); `brew info <formula>` (metadata + caveats); `brew doctor` (diagnose env). The "tap" concept: `brew tap <user>/<repo>` adds a third-party formula source.

Zshunix
brew install ripgrep

Same Ruby-on-macOS external. macOS-default zsh (since Catalina) is the canonical Homebrew shell — every install tutorial assumes zsh. Shell setup hook: Homebrew's installer writes `eval "$(/opt/homebrew/bin/brew shellenv)"` to `~/.zprofile`; that sets `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR`, prepends `/opt/homebrew/bin` to `PATH`. If `which brew` fails after install, the shellenv line wasn't sourced (open a new terminal, or source `~/.zprofile` manually).

Fishunix
brew install ripgrep

Same external. Fish-specific setup: instead of `eval "$(brew shellenv)"` (a bash idiom), use `eval (/opt/homebrew/bin/brew shellenv)` — fish's eval consumes the bash-style env exports. Better: add `/opt/homebrew/bin` to fish's `$fish_user_paths` once via `fish_add_path /opt/homebrew/bin` — survives shell restarts and is fish-idiomatic. Fish completions for `brew` ship with Homebrew via `brew --prefix`/`share/fish/`.

PowerShellwindows
winget install BurntSushi.ripgrep.MSVC

No native PowerShell brew — Windows uses `winget` / `choco` / `scoop`. On macOS pwsh, `brew` works identically: `& brew install <pkg>` from pwsh shells out to the macOS-native brew binary. For genuine "install Mac apps from pwsh on macOS" use `& brew install --cask <cask>`. The Linux pwsh + Linuxbrew combination works the same way but is rare; on Linux pwsh, `apt` / `dnf` / `pacman` is more idiomatic per distro.

cmd.exewindows
winget install BurntSushi.ripgrep.MSVC

No cmd-native equivalent. Windows alternatives: `winget` (official, since 2021), `choco` (community, broader Windows-app catalog, supports `--params` for installer flags), `scoop` (user-scope, no admin, focused on dev CLIs). `scoop install ripgrep` is the closest "developer-CLI-only" analog to `brew install ripgrep`. There is no native macOS-style Homebrew port to native Windows cmd — `brew` runs only on macOS (and Linux as Linuxbrew).

Worked examples

Install a CLI tool

Bash
brew install ripgrep
Fish
brew install ripgrep
PowerShell
winget install BurntSushi.ripgrep.MSVC
cmd.exe
choco install ripgrep -y

Install a GUI application (macOS Cask)

Bash
brew install --cask iterm2
Fish
brew install --cask iterm2
PowerShell
winget install --id Microsoft.WindowsTerminal
cmd.exe
choco install microsoft-windows-terminal -y

Update Homebrew, upgrade all packages, clean up old versions

Bash
brew update && brew upgrade && brew cleanup
Fish
brew update; and brew upgrade; and brew cleanup
PowerShell
winget upgrade --all

Gotchas

  • Apple Silicon vs Intel Mac install paths DIFFER — Apple Silicon (M1/M2/M3+) puts brew at `/opt/homebrew/`, Intel Macs use `/usr/local/`. Scripts that hard-code `/usr/local/bin/brew` break on M-series Macs. The canonical "find brew anywhere" is `$(command -v brew)`; tutorials that work on Intel Macs frequently fail silently on M-series until the user runs the shellenv eval. Note that the FIRST `brew install` on an M-series Mac initializes `/opt/homebrew/` and `git clone`s the formulas — takes ~2 minutes on a fresh system.
  • `brew install --cask` on macOS installs GUI apps into `/Applications/`, but the app gets QUARANTINED — first launch shows "are you sure you want to open this from the internet" Gatekeeper dialog. The non-cask `brew install` of CLI tools doesn't hit this. To bypass quarantine for cask installs: `brew install --cask --no-quarantine <cask>` (or `xattr -dr com.apple.quarantine /Applications/<App>.app` after install).
  • Homebrew on macOS is intentionally NOT root-owned — `/opt/homebrew/` is owned by your user, NOT `root`. Running `sudo brew install` is wrong and brew rejects it. This is a design choice: brew assumes one-user-per-Mac and avoids the security cost of root package installs. If you actually need a system-wide multi-user install with proper admin boundaries, brew is not the right tool — use `pkg` or `mas` (Mac App Store CLI) instead.
  • `brew update` updates Homebrew itself + the formula definitions; `brew upgrade` actually upgrades installed packages. Same `update` vs `upgrade` confusion as apt. Common Friday-afternoon script: `brew update && brew upgrade && brew cleanup && brew doctor` — refresh, upgrade, prune old versions, sanity-check. Without the trailing `cleanup`, old keg versions accumulate in `/opt/homebrew/Cellar/` and can eat tens of GB over a year.
  • Homebrew on Linux ("Linuxbrew", merged into Homebrew core in 2019) works but is rarely the right answer — your distro's apt/dnf/pacman has the package, usually faster + better integrated. Linuxbrew's sweet spot is dev tools NOT in your distro repos, on machines where you don't have root for apt/dnf. On WSL, prefer apt — Linuxbrew adds 1GB of dependencies and a separate user namespace for what apt already does.

WSL & PowerShell Core notes

pwshOn macOS pwsh, `brew` shells out directly: `& brew install <formula>`. On Linux pwsh, Linuxbrew works the same way but is overkill — prefer the distro manager. On Windows pwsh, no brew; use winget / choco / scoop. For a portable cross-OS pwsh install function: `if ($IsMacOS) { & brew install $name }; elseif ($IsLinux) { & sudo apt install -y $name }; elseif ($IsWindows) { winget install --id $name }`. Note: cross-OS package IDS rarely match (`ripgrep` on brew/apt, `BurntSushi.ripgrep.MSVC` on winget) — abstract a per-OS name map, not a single ID.
WSLWSL Ubuntu uses `apt`, not `brew` — Linuxbrew on WSL is technically possible but adds a separate user-namespace package manager on top of an already-functional apt. The common pattern is: native WSL `apt install <linux-tool>` for Linux-side tooling, `winget install <windows-tool>` from cmd/pwsh for Windows-side tooling. macOS-side: brew is the only answer on the host; from WSL you can't reach the Mac host's brew (no equivalent of WSL on macOS), but a Mac user running brew on the host can call into a Linux container via `docker run` or `multipass`.

Related commands