Last active
May 19, 2020 15:27
-
-
Save kingnebby/b904d14adaafb7680d7801c3c53fdeac to your computer and use it in GitHub Desktop.
add-proxies-to-your-env
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
# Pick a location to save your environment details | |
PROXY_FILE=$HOME/.my-env/proxies | |
# Source it so that new bash instances will pick up | |
# the current environment settings. | |
touch $PROXY_FILE | |
source <(cat $PROXY_FILE) | |
# Over-write the env file and soure it to ensure this window | |
# picks up the changes. | |
env-umbrellaCorp-set-proxy() { | |
echo "\\ | |
export http_proxy=http://umbrellaCorp.proxy-url.com:12345/;\\n\\ | |
export https_proxy=http://umbrellaCorp.proxy-url.com:12345/;\\n\\ | |
" > $PROXY_FILE | |
source <(cat $PROXY_FILE) | |
} | |
# Update configurations specific to NPM or any other | |
# tech you use (i.e. settings.xml) | |
env-umbrellaCorp-set-npm-config() { | |
echo "registry=https://umbrellaCorp-registry.com/artifactory/api/npm/npm/\\n\\ | |
https-proxy=http://umbrellaCorp.proxy-url.com:12345/\\n\\ | |
" > $HOME/.npmrc | |
} | |
# A short hand function to call all 'env' management | |
# functions | |
env-umbrellaCorp() { | |
env-umbrellaCorp-set-proxy; | |
env-umbrellaCorp-set-npm-config; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment