Skip to content

Instantly share code, notes, and snippets.

@janlay
Last active September 29, 2021 03:45
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janlay/2481bb44b384885ad509 to your computer and use it in GitHub Desktop.
Save janlay/2481bb44b384885ad509 to your computer and use it in GitHub Desktop.
Toogle Proxy in command line
#!/bin/bash
# 1. source this file or append it to your bash/zsh profile.
# 2. modify https_proxy & http_proxy with your own proxy.
# 3. use `proxy on` to turn on proxy and `proxy off` to turn it off.
export PS1_backup=$PS1
function proxy () {
local prefix
if [ "$1" = "on" ]; then
export https_proxy=http://127.0.0.1:8800
export http_proxy=http://127.0.0.1:8800
# echo Local HTTP Proxy is enabled.
prefix="😇"
else
unset https_proxy
unset http_proxy
# echo Local HTTP Proxy is disabled.
prefix="😑"
fi
export PS1="$prefix $PS1_backup"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment