Skip to content

Instantly share code, notes, and snippets.

@Esonhugh
Last active January 31, 2025 06:17
Show Gist options
  • Save Esonhugh/01526078cba6418e4814d91055fa3b3c to your computer and use it in GitHub Desktop.
Save Esonhugh/01526078cba6418e4814d91055fa3b3c to your computer and use it in GitHub Desktop.
proxy setting for your shell
# Date: 2025-01-31
# Author: Esonhugh
# proxy command to make you switch your commandline fastly
export PROXY_HOST="127.0.0.1" # define as your favour
export PROXY_PORT="7890" # define as your favour
proxys(){
case "$1" in
(h)
echo "|==============================================|"
echo "| $0 Usage |"
echo "| ---- fast commandline proxy switcher |"
echo "|==============================================|"
echo "| Basic Usage: $0 [SubCommand] [param1] |"
echo "|==============================================|"
echo "| Sub Command List |"
echo "|==============================================|"
echo "| proxy [proxy_ip] import ip temply |"
echo "| port [port_id] import port temply |"
echo "| loc import localhost |"
echo "| on up the cli proxy |"
echo "| off down the proxy |"
echo "| * show proxy setting |"
echo "| h/help show help |"
echo "|==============================================|"
;;
(proxy)
export PROXY_HOST="$2"
;;
(port)
export PROXY_PORT="$2"
;;
(loc)
export PROXY_HOST="127.0.0.1" # define as your favour
export PROXY_PORT="7890" # define as your favour
$0 on
;;
(on)
export https_proxy=http://$PROXY_HOST:$PROXY_PORT \
http_proxy=http://$PROXY_HOST:$PROXY_PORT \
all_proxy=socks5://$PROXY_HOST:$PROXY_PORT && \
echo 'export PROXY_HOST complete' && $0 show
;;
(off)
unset https_proxy http_proxy all_proxy && echo 'unset PROXY_HOST complete'
;;
(help)
proxys h
;;
(*)
echo "Current Proxy Condition like ...."
export|grep proxy
echo "if you can't see any output like 'XX_PROXY=' there"
echo "That means no proxy is set"
;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment