Last active
September 29, 2021 03:45
-
-
Save janlay/2481bb44b384885ad509 to your computer and use it in GitHub Desktop.
Toogle Proxy in command line
This file contains hidden or 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
#!/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