Making the PATH and other environment variables available in emacs

If your environment variables are being set in ~/.bash_profile, Create a file called ~/.emacs_bash and put in it the following:

. ~/.bash_profile

Don't forget the newline at the end of that line or it won't be executed.

~/.emacs_bash is loaded by emacs when you run bash from within it, such as when using M-x shell or shell-command so you can use it to set any environment variables you want available.


Just install the awesome little package exec-path-from-shell and you're done! It will automatically set your emacs exec-path to be same as the PATH in your zsh/bash config.

It will also allow you to copy the values of other shell variables like this:

(exec-path-from-shell-copy-env "PYTHONPATH")