How can I configure eshell to be able to run programs from directories in PATH env variable?
How can I add additional custom directories to the list?
I use Emacs 24.3.1.
The Emacs equivalent of the PATH environment variable is exec-path
, which is a list instead of a colon-separated string.
Its content it initialized with the value of PATH, so supposedly it should be all transparent. But if this happens not to contain what you want (typically when Emacs is not run from a shell, but from a Desktop Environment), you might find this package useful: exec-path-from-shell. Install it from Marmalade or MELPA using
M-x package-install exec-path-from-shell RET
.profile
, not in .bashrc
.
Commented
Sep 29, 2014 at 18:21
export PATH=...
to ~/.profile
did not work for me. I still see PATH
set to value created by desktop environment.
Commented
Sep 29, 2014 at 20:45
$PATH
does not make eshell see them, at least not on my system.
Commented
Feb 11, 2018 at 18:38
You can configure TRAMP to respect the PATH variable on the remote machine (for remote eshell sessions) by adding 'tramp-own-remote-path
to the list 'tramp-remote-path
:
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
By default, eshell will not adopt the remote PATH settings.
~/.bash_profile
(contrary to ~/.profile
) which I have seen in some docs concerning these tramp-*
vars...
Commented
Jan 26, 2015 at 20:03
For a clear answer to part 2 (How can I add additional custom directories to the list?):
You can use the following elisp to customize your exec-path
variable to include any additional directories
(add-to-list 'exec-path "/custom/directory/path")
Although the other answers specify how to add to your $PATH
(%PATH%
on Windows) there are cases where this is not really a solution, particularly in a Windows environment.
Suppose you have Cygwin installed and do not want to include c:\cygwin\bin
in %PATH%
(user or system) because it will overwrite certain DOS built-in commands (Find
) and could break any scripts that call them.
Adding it directly to exec-path
within Emacs on startup can ensure you get full access to those tools within the editor, without installing Cygwin Emacs.
exec-path
but the directories in which Eshell's which
is searching does not change.
To answer to your first question: Eshell is already able to run programs in PATH. Here's an example:
Welcome to the Emacs shell
~ $ env-info
manuel@bebop
OS: LinuxBBQ Haggis
Uptime: 0d 4h 9m
Shell: /bin/zsh
WM: ratpoison
Disk: 37G / 257G
Mem: 1180M / 4042M
Kernel: Linux 3.16-2-686-pae i686
CPU: Intel(R) Core(TM)2 Duo CPU T6400 @ 2.00GHz
~ $ which env-info
/home/manuel/bin/env-info
~ $ echo $PATH | grep bin
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/manuel/bin
For an even clearer answer to part 2 (How can I add additional custom directories to the list?): [this adds the current directory]
addpath (pwd)
or to add something relative to your current directory
addpath $(pwd)subdir1/subdir2
https://www.gnu.org/software/emacs/manual/html_mono/eshell.html