Last active
November 12, 2015 12:54
-
-
Save sebasmagri/9727631 to your computer and use it in GitHub Desktop.
Set Emacs executables PATH to the one used by interactive shells
This file contains 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
;;; Put this in your .emacs file. | |
;;; PATH used by default in emacs is not that used in interactive shells. Thus, it would miss | |
;;; paths set in the shell's rc file. | |
;;; The login shell could print warnings or errors on initialization, so we isolate the PATH and | |
;;; use a simple regexp to get the real value | |
(let ((interactive-shell-path (shell-command-to-string "$SHELL -l -i -c 'echo \"***\n$PATH\n***\"'"))) | |
(string-match ".*\\*\\*\\*\\\n\\(.*\\)\n\\*\\*\\*.*" interactive-shell-path) | |
(let ((clean-shell-path (match-string 1 interactive-shell-path))) | |
(setenv "PATH" clean-shell-path) ;;; normal PATH | |
(setq eshell-path-env clean-shell-path) ;;; PATH in eshell | |
(setq exec-path (split-string clean-shell-path path-separator)) ;;; exec-path | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is based on http://www.verious.com/qa/how-to-make-emacs-to-use-my-bashrc-file/