Bladeren bron

Change env-specific proxy settings to `setproxy()`

The environment specific proxy settings should not be controlled by a
generic dotfiles installation and are now part of `~/.zshlocal`, with
modifications to use `setproxy()`:

    alias proxy="setproxy http://192.168.1.248"
    alias noproxy="setproxy"

    if [ `ifconfig | grep 10.10.0 | wc -l` = 1 ]; then
    ...
    ...
Weiyi Lou 10 jaren geleden
bovenliggende
commit
90ccb52bee
1 gewijzigde bestanden met toevoegingen van 11 en 16 verwijderingen
  1. 11 16
      zsh/custom/proxy.zsh

+ 11 - 16
zsh/custom/proxy.zsh

@@ -1,16 +1,11 @@
-#
-# Proxy settings
-# Thanks to:
-# https://github.com/dangerous/dotfiles
-#
-# TODO: The setting of the IP should be perhaps moved to a zshlocal file.
-alias proxy='export http_proxy=http://192.168.1.248:3128;export HTTP_PROXY=$http_proxy;export https_proxy=$http_proxy;export HTTPS_PROXY=$http_proxy;export ftp_proxy=$http_proxy;export FTP_PROXY=$http_proxy;'
-alias noproxy='export http_proxy='';export HTTP_PROXY=$http_proxy;export https_proxy=$http_proxy;export HTTPS_PROXY=$http_proxy;export ftp_proxy=$http_proxy;export FTP_PROXY=$http_proxy;'
-
-# run only if I am at work
-if [ `ifconfig | grep 10.10.0 | wc -l` = 1 ]; then
-    proxy
-fi
-if [ `ifconfig | grep 192.168.2 | wc -l` = 1 ]; then
-    proxy
-fi
+# Set proxy environment variables
+function setproxy() {
+  proxy_address=${1:-}
+  export HTTP_PROXY=$proxy_address
+  export HTTPS_PROXY=$proxy_address
+  export FTP_PROXY=$proxy_address
+  export http_proxy=$proxy_address
+  export https_proxy=$proxy_address
+  export ftp_proxy=$proxy_address
+  echo "Proxy envvars set to '$proxy_address'"
+}