Skip to content

Instantly share code, notes, and snippets.

@abn
Last active January 5, 2023 09:24
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save abn/07cc147bafb85d3b8ab5f53d1e239926 to your computer and use it in GitHub Desktop.
Save abn/07cc147bafb85d3b8ab5f53d1e239926 to your computer and use it in GitHub Desktop.
Install homebrew from behind a proxy on Mac OS X.
#!/usr/bin/env bash
# Based on: http://godlessheathenmemoirs.blogspot.com.au/2015/03/homebrew-aka-brew-on-mac-os-x-behind.html
function usage() {
echo 2>&1 ""
echo 2>&1 "usage: $(basename $0) PROXY_HOST PROXY_PORT"
exit 1
}
PROXY_HOST=${PROXY_HOST:-$1}
PROXY_PORT=${PROXY_PORT:-$2}
[ -z "${PROXY_HOST}" ] && { echo 1>&2 "PROXY_HOST not defined"; usage; }
[ -z "${PROXY_PORT}" ] && { echo 1>&2 "PROXY_PORT not defined"; usage; }
PROXY_URI=${PROXY_HOST}:${PROXY_PORT}
# export proxy environment configurations
declare -x HTTPS_PROXY="http://${PROXY_URI}"
declare -x HTTP_PROXY="http://${PROXY_URI}"
declare -x http_proxy="http://${PROXY_URI}"
declare -x https_proxy="http://${PROXY_URI}"
# ignore TLS issues when cloning from git (homebrew)
declare -x GIT_SSL_NO_VERIFY="1"
# there really should be a better way; sigh
# source: https://brew.sh/
ruby -e "$(curl -x http://${PROXY_URI} -fsSL -k https://raw.githubusercontent.com/Homebrew/install/master/install)"
@akeschmidi
Copy link

update to the new url /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

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