cite about-plugin about-plugin 'Proxy Tools' disable-proxy () { about 'Disables proxy settings for Bash, npm and SSH' group 'proxy' unset http_proxy unset https_proxy unset HTTP_PROXY unset HTTPS_PROXY unset ALL_PROXY unset no_proxy unset NO_PROXY echo "Disabled proxy environment variables" npm-disable-proxy ssh-disable-proxy svn-disable-proxy } enable-proxy () { about 'Enables proxy settings for Bash, npm and SSH' group 'proxy' export http_proxy=$BASH_IT_HTTP_PROXY export https_proxy=$BASH_IT_HTTPS_PROXY export HTTP_PROXY=$http_proxy export HTTPS_PROXY=$https_proxy export ALL_PROXY=$http_proxy export no_proxy=$BASH_IT_NO_PROXY export NO_PROXY=$no_proxy echo "Enabled proxy environment variables" npm-enable-proxy ssh-enable-proxy svn-enable-proxy } enable-proxy-alt () { about 'Enables alternate proxy settings for Bash, npm and SSH' group 'proxy' export http_proxy=$BASH_IT_HTTP_PROXY_ALT export https_proxy=$BASH_IT_HTTPS_PROXY_ALT export HTTP_PROXY=$http_proxy export HTTPS_PROXY=$https_proxy export ALL_PROXY=$http_proxy export no_proxy=$BASH_IT_NO_PROXY export NO_PROXY=$no_proxy echo "Enabled alternate proxy environment variables" npm-enable-proxy $http_proxy $https_proxy ssh-enable-proxy svn-enable-proxy $http_proxy } show-proxy () { about 'Shows the proxy settings for Bash, Git, npm and SSH' group 'proxy' echo "" echo "Environment Variables" echo "=====================" env | grep -i "proxy" | grep -v "BASH_IT" bash-it-show-proxy npm-show-proxy git-global-show-proxy svn-show-proxy ssh-show-proxy } proxy-help () { about 'Provides an overview of the bash-it proxy configuration' group 'proxy' cat << EOF Bash-it provides support for enabling/disabling proxy settings for various shell tools. The following backends are currently supported (in addition to the shell's environment variables): Git, SVN, npm, ssh Bash-it uses the following variables to set the shell's proxy settings when you call 'enable-proxy'. These variables are best defined in a custom script in bash-it's custom script folder ('$BASH_IT/custom'), e.g. '$BASH_IT/custom/proxy.env.bash' * BASH_IT_HTTP_PROXY and BASH_IT_HTTPS_PROXY: Define the proxy URL to be used, e.g. 'http://localhost:1234' * BASH_IT_NO_PROXY: A comma-separated list of proxy exclusions, e.g. '127.0.0.1,localhost' Run 'glossary proxy' to show the available proxy functions with a short description. EOF bash-it-show-proxy } bash-it-show-proxy () { about 'Shows the bash-it proxy settings' group 'proxy' echo "" echo "bash-it Environment Variables" echo "=============================" echo "(These variables will be used to set the proxy when you call 'enable-proxy')" echo "" env | grep -e "BASH_IT.*PROXY" } npm-show-proxy () { about 'Shows the npm proxy settings' group 'proxy' if $(command -v npm &> /dev/null) ; then echo "" echo "npm" echo "===" echo "npm HTTP proxy: " `npm config get proxy` echo "npm HTTPS proxy: " `npm config get https-proxy` echo "npm proxy exceptions: " `npm config get noproxy` fi } npm-disable-proxy () { about 'Disables npm proxy settings' group 'proxy' if $(command -v npm &> /dev/null) ; then npm config delete proxy npm config delete https-proxy npm config delete noproxy echo "Disabled npm proxy settings" fi } npm-enable-proxy () { about 'Enables npm proxy settings' group 'proxy' local my_http_proxy=${1:-$BASH_IT_HTTP_PROXY} local my_https_proxy=${2:-$BASH_IT_HTTPS_PROXY} local my_no_proxy=${3:-$BASH_IT_NO_PROXY} if $(command -v npm &> /dev/null) ; then npm config set proxy $my_http_proxy npm config set https-proxy $my_https_proxy npm config set noproxy $my_no_proxy echo "Enabled npm proxy settings" fi } git-global-show-proxy () { about 'Shows global Git proxy settings' group 'proxy' if $(command -v git &> /dev/null) ; then echo "" echo "Git (Global Settings)" echo "=====================" echo "Git (Global) HTTP proxy: " `git config --global --get http.proxy` echo "Git (Global) HTTPS proxy: " `git config --global --get https.proxy` fi } git-global-disable-proxy () { about 'Disables global Git proxy settings' group 'proxy' if $(command -v git &> /dev/null) ; then git config --global --unset-all http.proxy git config --global --unset-all https.proxy echo "Disabled global Git proxy settings" fi } git-global-enable-proxy () { about 'Enables global Git proxy settings' group 'proxy' if $(command -v git &> /dev/null) ; then git-global-disable-proxy git config --global --add http.proxy $BASH_IT_HTTP_PROXY git config --global --add https.proxy $BASH_IT_HTTPS_PROXY echo "Enabled global Git proxy settings" fi } git-show-proxy () { about 'Shows current Git project proxy settings' group 'proxy' if $(command -v git &> /dev/null) ; then echo "Git Project Proxy Settings" echo "=====================" echo "Git HTTP proxy: " `git config --get http.proxy` echo "Git HTTPS proxy: " `git config --get https.proxy` fi } git-disable-proxy () { about 'Disables current Git project proxy settings' group 'proxy' if $(command -v git &> /dev/null) ; then git config --unset-all http.proxy git config --unset-all https.proxy echo "Disabled Git project proxy settings" fi } git-enable-proxy () { about 'Enables current Git project proxy settings' group 'proxy' if $(command -v git &> /dev/null) ; then git-disable-proxy git config --add http.proxy $BASH_IT_HTTP_PROXY git config --add https.proxy $BASH_IT_HTTPS_PROXY echo "Enabled Git project proxy settings" fi } svn-show-proxy () { about 'Shows SVN proxy settings' group 'proxy' if $(command -v svn &> /dev/null) && $(command -v python2 &> /dev/null) ; then echo "" echo "SVN Proxy Settings" echo "==================" python2 - < /dev/null) && $(command -v python2 &> /dev/null) ; then python2 - < /dev/null) && $(command -v python2 &> /dev/null) ; then local my_http_proxy=${1:-$BASH_IT_HTTP_PROXY} python2 - "$my_http_proxy" "$BASH_IT_NO_PROXY" <