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 |