Last active
December 15, 2023 01:58
-
-
Save pplmx/7e21bd07ecba53a4617325d9a60fe01b to your computer and use it in GitHub Desktop.
simplify some common proxy config
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 | |
# define color | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
NC='\033[0m' # No Color | |
function enable_proxy() { | |
git config --global http.proxy "$1" | |
git config --global https.proxy "$1" | |
npm config set proxy "$1" | |
export {all,http,https}_proxy="$1" | |
echo -e "${GREEN}Proxy enabled${NC}" | |
} | |
function disable_proxy() { | |
git config --global --unset http.proxy | |
git config --global --unset https.proxy | |
npm config delete proxy | |
unset {all,http,https}_proxy | |
echo -e "${RED}Proxy disabled${NC}" | |
} | |
if [ "$1" == "enable" ] && [ -n "$2" ]; then | |
enable_proxy "$2" | |
elif [ "$1" == "disable" ]; then | |
disable_proxy | |
else | |
echo "Usage: $0 enable <proxy_url> | $0 disable" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment