Skip to content

Instantly share code, notes, and snippets.

@josephschmitt
Last active February 16, 2022 18:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephschmitt/6f426db08440c5c9589ec0cbf420a2a0 to your computer and use it in GitHub Desktop.
Save josephschmitt/6f426db08440c5c9589ec0cbf420a2a0 to your computer and use it in GitHub Desktop.
# Usage:
# $ switch_brew (uname -m)
# $ switch_brew x86_64
# $ switch_brew arm64
function switch_brew
set -l arm_brew_path "/opt/homebrew/bin"
set -l switch_to $argv[1]
if test "$switch_to" = "x86_64"
if set -l index (contains -i $arm_brew_path $PATH)
set -e PATH[$index]
end
else if test "$switch_to" = "arm64"
set PATH $arm_brew_path $PATH
end
end
@josephschmitt
Copy link
Author

josephschmitt commented Sep 23, 2021

This file should be added to ~/.config/fish/functions/switch_brew.fish. Then add this line to your ~/.config/fish/config.fish file to automatically set the correct brew on startup:

switch_brew (uname -m)

See homebrew's installation instructions for more context, or this explanation.

Additionally, this blog post goes into more explanation on the multi-brew setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment