How can I install Homebrew into /opt/?

I've used the script written by Noah Rubin;

/bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/nrubin29/bea5aa83e8dfa91370fe83b62dad6dfa/raw/48f48f7fef21abb308e129a80b3214c2538fc611/homebrew_m1.sh)"

worked like a charm! Here is his youtube video on this topic for more info; https://youtu.be/nv2ylxro7rM

Edit: Forgot to mention, this script installs the homebrew into /opt/homebrew


I solved it running under the Rosetta Terminal

  1. Locate the Terminal application within the Utilities folder (Finder> Go menu > Utilities)

  2. Select Terminal.app and right-click on it, then choose “Duplicate” Rename the duplicated Terminal app something obvious and distinct, like ‘Rosetta Terminal’

  3. Now select the freshly renamed ‘Rosetta Terminal’ app and right-click and choose “Get Info” (or hit Command+i)

  4. Check the box for “Open using Rosetta”, then close the Get Info window Run the “Rosetta Terminal” as usual, which will fully support Homebrew and other x86 command line apps