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
?
In order to set a permanent environment variable in Bash, you have to use the export command and add it either to your “. bashrc” file (if this variable is only for you) or to the /etc/environment file if you want all users to have this environment variable.
Eshell is a shell written entirely in Emacs Lisp, and it replicates most of the features and commands from GNU CoreUtils and the Bourne-like shells. So by re-writing common commands like ls and cp in Emacs-Lisp, Eshell will function identically on any environment Emacs itself runs on.
emacs . You can set PATH using (setenv "PATH" (format "%s:%s" "/new/path/element" (getenv "PATH"))) .
Emacs exec-path Emacs has a variable named exec-path . Its value is a list of dir paths. Emacs uses exec-path to find executable binary programs.
~ $ (setenv "XYZ" "abc")
abc
~ $ ./e.sh
abc
~ $ cat e.sh
echo $XYZ
~ $ (setenv "XYZ" "abc")
abc
~ $ ./e.sh
abc
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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With