-
-
Save yankchina/8538162 to your computer and use it in GitHub Desktop.
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
prox="http://proxy.com:8080" | |
alias proxyon="export http_proxy=$prox && export https_proxy=$prox" | |
alias proxyoff='unset http_proxy && unset https_proxy' | |
echo "Turning http(s) proxies on" | |
proxyon | |
# investigate function is repeated here for portability but, we | |
# only define it if investigate isn't already a defined function | |
if ! type -t investigate &> /dev/null; then | |
function investigate { | |
local output_prefix='' # could be something like [*] | |
local output_sep=": " # could be ", " ": " etc | |
for varname in $@; do | |
echo -n "${output_prefix}${varname}${output_sep}" | |
v='echo $' | |
v="${v}$(echo $varname)" | |
eval $v | |
done | |
} | |
export -f investigate | |
fi | |
# Display the state of the proxy variables | |
function proxystate { | |
local HTTP="off" | |
local HTTPS="off" | |
local SOCKS="off" | |
if export | grep -q http_proxy;then | |
HTTP=$http_proxy | |
fi | |
if export | grep -q https_proxy;then | |
HTTPS=$https_proxy | |
fi | |
if export | grep -q socks_proxy;then | |
SOCKS=$socks_proxy | |
fi | |
echo "[*] Current state of proxy variables" | |
investigate HTTP HTTPS SOCKS | |
} | |
export -f proxystate | |
proxystate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment