Skip to content

Instantly share code, notes, and snippets.

@kiding
Last active February 24, 2022 15:21
Show Gist options
  • Save kiding/d77a418b81a5871daddc76e5f0d6cf36 to your computer and use it in GitHub Desktop.
Save kiding/d77a418b81a5871daddc76e5f0d6cf36 to your computer and use it in GitHub Desktop.
Heterogeneous Homebrew: Apple Silicon & Intel Rosetta 2 side-by-side
# Install Homebrew at /opt/homebrew (for Apple Silicon)
arch -arm64e /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Homebrew at /usr/local (for Intel Rosetta 2)
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add these lines to ~/.zshrc
alias za="arch -arch arm64e /bin/zsh"
alias zi="arch -arch x86_64 /bin/zsh"
if [[ $(arch) == "arm64" ]]; then
PS1="%{$fg_bold[red]%}🐇%{$reset_color%} $PS1"
PATH="/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/local/sbin:$PATH"
else
PS1="%{$fg_bold[red]%}🐢%{$reset_color%} $PS1"
PATH="/usr/local/bin:/usr/local/sbin:/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
fi
# Usage
# - Run `za` to switch to Apple Silicon shell & Homebrew
# - Run `zi` to switch to Intel Rosetta 2 shell & Homewbrew
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment