Skip to content

Instantly share code, notes, and snippets.

@sfelix-martins
Created February 14, 2020 12:37
Show Gist options
  • Save sfelix-martins/494a42fc7138c8f66848646c194e05de to your computer and use it in GitHub Desktop.
Save sfelix-martins/494a42fc7138c8f66848646c194e05de to your computer and use it in GitHub Desktop.

Usage

Paste the gist code in your .zshrc or .bashrc and run source ~/.zshrc or source ~/.bashrc.

Every time you switch the internet adapter you must run source ~/.zshrc again.

# Define proxy only if is connected on cable
export http_proxy='';
export https_proxy='';
export adapter=$(networksetup -listallhardwareports | grep -C1 $(route get default | grep interface | awk '{print $2}'))
if [[ $adapter == *"LAN"* ]]; then
export http_proxy=PROXY_HOST:PROXY_PORT
export https_proxy=PROXY_HOST:PROXY_PORT
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment