changing the path on the emacs eshell

The emacs eshell is an interactive shell for entering commands written in elisp. I like it because it feels like a normal emacs buffer and I can easily move around and copy and paste, without switching to a copy mode. It loses many of the features of bash, but when I need them I can use bash, inside or outside of emacs.

I had a hard time figuring out how to set the path it uses when I type commands, though. I wound up finding a way that worked for me by reading the source of the which function and then the code of eshell-search-path, which the which function uses to find executables in the path.

The variable is eshell-path-env and it’s a colon-separated list of directories. I needed to add my nodebrew directory to it, and I did so by adding the following to ~/.emacs.d/init.el:

(setq eshell-path-env (concat "/Users/bat/.nodebrew/current/bin" ":" eshell-path-env))

I’m not sure that this is the best answer, but it took me a while to find and answer that worked so I thought I’d share it.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.