Skip to content

Instantly share code, notes, and snippets.

@Esonhugh
Last active July 10, 2022 15:55
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: 2022-07-10
# Author: Esonhugh
# proxy command to make you switch your commandline fastly
export clash="127.0.0.1" # define as your favour
export portOfClash="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 clash="$2"
;;
(port)
export portOfClash="$2"
;;
(loc)
export clash="127.0.0.1" # define as your favour
export portOfClash="7890" # define as your favour
$0 on
;;
(on)
export https_proxy=http://$clash:$portOfClash \
http_proxy=http://$clash:$portOfClash \
all_proxy=socks5://$clash:$portOfClash && \
echo 'export clash complete' && $0 show
;;
(off)
unset https_proxy http_proxy all_proxy && echo 'unset clash 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