18

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?

serv-inc
  • 35,772
  • 9
  • 166
  • 188
Palace Chan
  • 8,845
  • 11
  • 41
  • 93

2 Answers2

23
~ $ (setenv "XYZ" "abc")
abc
~ $ ./e.sh
abc
~ $ cat e.sh
echo $XYZ
~ $ (setenv "XYZ" "abc")
abc
~ $ ./e.sh
abc
Miserable Variable
  • 28,432
  • 15
  • 72
  • 133
3

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))
jekennedy
  • 1,192
  • 10
  • 17