~ $ (setenv "XYZ" "abc")
abc
~ $ ./e.sh
abc
~ $ cat e.sh
echo $XYZ
~ $ (setenv "XYZ" "abc")
abc
~ $ ./e.sh
abc
How to set an environment variable in emacs shell (eshell)?
-
06-03-2022 - |
Question
I cannot seem to find this anywhere. A lot of times I run commands with an environment variable set like:
export BLA=foo && ./somebinary
How do i do this in eshell
? I think the command is called set
but i'm not sure how to use it, what would be the above equivalent in eshell
?
La solution
Autres conseils
I set variables in my bash profile like so:
export WORK_DIR=/Users/me/Documents/some/dir
Then in .emacs I put this:
(let ((work_dir (shell-command-to-string ". ~/.bash_profile; echo -n $WORK_DIR")))
(setenv "WORK_DIR" work_dir))
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow