Created
November 23, 2017 00:39
-
-
Save timothystone/6453449a56e126b6ad3344c4d43451b1 to your computer and use it in GitHub Desktop.
How I set my proxy in ZSH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#in ZSH, add to ~/.zprofile | |
set_http_proxy() { | |
if [ -e $HOME/.proxyrc ]; then | |
. $HOME/.proxyrc | |
fi | |
if [ -z $http_proxy ]; then | |
echo "No proxy config, environment found, connection attempt failed." | |
echo "Let's setup a config or update your password." | |
read 'eid?eID: ' | |
read -s 'password?Password: ' | |
http_proxy="http://${eid}:${password}@<your.proxy.net:port>/" | |
https_proxy="http://${eid}:${password}@<your.proxy.net:port>/" | |
echo "export http_proxy=$http_proxy" > $HOME/.proxyrc | |
echo "export HTTP_PROXY=$http_proxy" >> $HOME/.proxyrc | |
echo "export https_proxy=$https_proxy" >> $HOME/.proxyrc | |
echo "export HTTPS_PROXY=$https_proxy" >> $HOME/.proxyrc | |
. $HOME/.proxyrc | |
fi | |
} | |
kill_http_proxy() { | |
rm $HOME/.proxyrc | |
unset_http_proxy | |
} | |
unset_http_proxy() { | |
unset http_proxy | |
unset HTTP_PROXY | |
unset https_proxy | |
unset HTTPS_PROXY | |
} | |
# set the proxy | |
set_http_proxy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good stuff!
In mine settings, I don't like to key in my EID every time. So I just hard code it. And on line #14, I refer to the variable defined in #13.