Skip to content

Instantly share code, notes, and snippets.

@ddeaguiar
Created August 23, 2013 14:10
Show Gist options
  • Save ddeaguiar/6319724 to your computer and use it in GitHub Desktop.
Save ddeaguiar/6319724 to your computer and use it in GitHub Desktop.
(defun set-exec-path-from-shell-PATH ()
"Set up Emacs' `exec-path' and PATH environment variable to match that used by the user's shell.
This is particularly useful under Mac OSX, where GUI apps are not started from a shell."
(interactive)
(let ((path-from-shell (replace-regexp-in-string "[ \t\n]*$" "" (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
(setenv "PATH" path-from-shell)
(setq exec-path (split-string path-from-shell path-separator))))
(set-exec-path-from-shell-PATH)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment