Skip to content

Instantly share code, notes, and snippets.

@bibendi
Last active December 24, 2021 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bibendi/40562d96d817bd85376b3d6ab31585c4 to your computer and use it in GitHub Desktop.
Save bibendi/40562d96d817bd85376b3d6ab31585c4 to your computer and use it in GitHub Desktop.
Dual architecture on M1 Apple Silicon
# Homebrew
_ARCH=$(arch)
PROMPT="$_ARCH $PROMPT"
if [[ "$_ARCH" == "i386" ]]; then
local brew_path="/usr/local/homebrew/bin"
local brew_opt_path="/usr/local/homebrew/opt"
local nvm_path="$HOME/.nvm-x86"
local rbenv_path="$HOME/.rbenv-x86"
fi
if [[ "$_ARCH" == "arm64" ]]; then
local brew_path="/opt/homebrew/bin"
local brew_opt_path="/opt/homebrew/opt"
local nvm_path="$HOME/.nvm"
local rbenv_path="$HOME/.rbenv"
fi
export PATH="${brew_path}:${brew_opt_path}:${PATH}"
# Node
# https://seannicdao.com/2021/02/dual-install-homebrew-nvm-and-node-on-apple-m1/
export NVM_DIR="${nvm_path}"
[ -s "${brew_opt_path}/nvm/nvm.sh" ] && \. "${brew_opt_path}/nvm/nvm.sh" # This loads nvm
[ -s "${brew_opt_path}/nvm/etc/bash_completion.d/nvm" ] && \. "${brew_opt_path}/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
# Ruby
export RBENV_ROOT="${rbenv_path}"
eval "$(rbenv init - zsh)"
# Dip
dip version > /dev/null 2>&1 && eval "$(dip console)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment