Skip to content

Instantly share code, notes, and snippets.

@ageekymonk
Last active May 8, 2020 14:59
Show Gist options
  • Save ageekymonk/bed829c85a0bb8ef42e1bbc443fa4544 to your computer and use it in GitHub Desktop.
Save ageekymonk/bed829c85a0bb8ef42e1bbc443fa4544 to your computer and use it in GitHub Desktop.
spacemacs
;;;; Proxy
(defun module/proxy ()
"Set Proxy"
(defun set-work-proxy ()
"Set your work proxy."
(interactive)
;; Set proxy configurations in emacs
(setq url-proxy-services
'(("no_proxy" . "^\\(localhost\\|127.0.0.1\\)")
("http" . "localhost:3128")
("https" . "localhost:3128")))
;; Set environment variables for shell to work
(setenv "no_proxy" "^\\(localhost\\|127.0.0.1\\)")
(setenv "http_proxy" "http://localhost:3128")
(setenv "https_proxy" "http://localhost:3128")
;; Set git configuration to include proxy
(setq magit-git-global-arguments '("--no-pager" "--literal-pathspecs" "-c" "core.preloadindex=true" "-c" "log.showSignature=false" "-c" "http.proxy=localhost:3128")))
(defun unset-work-proxy ()
"Unset your work proxy."
(interactive)
;; Set the proxy to nil
(setq url-proxy-services nil)
(setenv "no_proxy" "") ; Set the environment to null as some emacs library relies on this.
(setenv "http_proxy" "")
(setenv "https_proxy" "")
;; Set the git config proxy to nil.
(setq magit-git-global-arguments '("--no-pager" "--literal-pathspecs" "-c" "core.preloadindex=true" "-c" "log.showSignature=false")))
(spacemacs/set-leader-keys (kbd "pw") 'set-work-proxy)
(spacemacs/set-leader-keys (kbd "pW") 'unset-work-proxy))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment