Created
March 15, 2012 20:13
-
-
Save bradwright/2046593 to your computer and use it in GitHub Desktop.
Set Emacs exec-path by shell $PATH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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: | |
;; | |
;; http://developer.apple.com/library/mac/#qa/qa1067/_index.html | |
;; | |
;; 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 | |
(replace-regexp-in-string | |
"[[: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 | |
(set-exec-path-from-shell-PATH) |
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
Great stuff! Thank you!