Skip to content

Instantly share code, notes, and snippets.

@bradwright bradwright/path.el
Created Mar 15, 2012

What would you like to do?
Set Emacs exec-path by shell $PATH
;; This sets the Emacs "PATH" environment variable and the `exec-path`
;; variable to the same value your login shell sees. The reason this
;; is necessary is because of this:
;; Basically apps launched from Finder inherit their environment from
;; a .plist file rather than the shell environment.
(defun set-exec-path-from-shell-PATH ()
"Sets the exec-path to the same value used by the user shell"
(let ((path-from-shell
"[[:space:]\n]*$" ""
(shell-command-to-string "$SHELL -l -c 'echo $PATH'"))))
(setenv "PATH" path-from-shell)
(setq exec-path (split-string path-from-shell path-separator))))
;; call function now

This comment has been minimized.

Copy link

commented Dec 3, 2014

Great stuff! Thank you!


This comment has been minimized.

Copy link

commented Aug 11, 2015

Yes, I like how short and sweet this is! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.