Skip to content

Instantly share code, notes, and snippets.

@kingnebby
Last active May 19, 2020 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kingnebby/b904d14adaafb7680d7801c3c53fdeac to your computer and use it in GitHub Desktop.
Save kingnebby/b904d14adaafb7680d7801c3c53fdeac to your computer and use it in GitHub Desktop.
add-proxies-to-your-env
# 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