Created
June 8, 2022 00:01
-
-
Save carloswm85/3d22fb0337b5423989008204ec3a3981 to your computer and use it in GitHub Desktop.
Bash script functions for quickly setting and unsetting proxy configurations. Includes examples.
This file contains 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
function proxy { | |
YW='\033[0;33m' # Yellow | |
NC='\033[0m' # No Color | |
SB='\033[1;34m' # Sky Blue | |
PP='\033[1;35m' # Purple | |
printf "\n${YW}How to set and unset proxy using Git Bash: ${NC}" | |
printf "\n${PP}Check:" | |
printf "\n${NC} $ git config --global --list" | |
printf "\n${PP}SET (Example):" | |
printf "\n${NC} $ http.proxy=http://username:password@proxyaddress:port" | |
printf "\n${NC} $ https.proxy=https://username:password@proxyaddress:port" | |
printf "\n${PP}UNSET:" | |
printf "\n${NC} $ git config --global --unset http.proxy" | |
printf "\n${NC} $ git config --global --unset https.proxy" | |
printf "\n" | |
printf "\n${SB}1) My local settings (reminder):" | |
printf "\n${NC} $ git config --global http.proxy http://:@10.1.343.254:80" | |
printf "\n${NC} $ git config --global https.proxy https://:@10.1.343.254:80" | |
printf "\n" | |
} | |
function proxyoff { | |
YW='\033[0;33m' # Yellow | |
NC='\033[0m' # No Color | |
SB='\033[1;34m' # Sky Blue | |
PP='\033[1;35m' # Purple | |
printf "\n${YW}(1) Proxy OFF... ${NC}" | |
printf "\n${PP}Current configuration: ${NC}\n" | |
git config --global --list | |
printf "\n${SB}(2) UNSETTING... ${NC}" | |
git config --global --unset http.proxy | |
git config --global --unset https.proxy | |
printf "\n${PP}New configuration: ${NC}\n" | |
git config --global --list | |
} | |
function proxyon { | |
YW='\033[0;33m' # Yellow | |
NC='\033[0m' # No Color | |
SB='\033[1;34m' # Sky Blue | |
PP='\033[1;35m' # Purple | |
printf "\n${YW}(1) Proxy ON... ${NC}" | |
printf "\n${PP}Current configuration: ${NC}\n" | |
git config --global --list | |
printf "\n${SB}(2) SETTING... ${NC}" | |
git config --global http.proxy http://:@10.1.343.254:80 | |
git config --global https.proxy https://:@10.1.343.254:80 | |
printf "\n${PP}New configuration: ${NC}\n" | |
git config --global --list | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment