Environment Variables and Eshell (publ. 2024-09-24)

I'm presenting an Emacsconf talk this year called "Emacs as a Shell", so I've been thinking a lot about if and how Emacs can fulfill various functions that are traditionally fulfilled by a shell such as bash. One such function is managing environment variables.

Emacs is certainly capable of reading and setting environment variables. Through elisp calls, you can run elisp functions getenv, printenv, and setenv. From what I can tell, setenv sets the environment variable for that entire Emacs session, so that subprocesses launched by Emacs will get that environment variable.

Things are a little more subtle when you are working within Eshell, as each Eshell has its own environment. A new Eshell will inherit Emacs' general environment, or the environment passed to it by the Eshell, if launched by another Eshell.

Environment variables can be significant for a variety of things, such as

The environment is very important in Guix Gnu/Linux, because almost nothing is stored in standard directories. Rather, the environment, provided by the current profile, determines what programs and libraries are exposed. These in turn are stored by hash inside the Guix store (usually /gnu/store).

Something I've been trying to explore, for the last few lunch breaks, is if it would be possible to use "guix shell" within Eshell - without leaving Eshell. The "guix shell" program allows you to specify any kind of profile you want — e.g., an extra program that is not installed as part of your normal profile. Then it drops you into a new bash shell with the appropriate environment for that profile.

It would be nice to be able to do the same thing but end up in Eshell instead. The tricky part is that eshell is not a stand-alone program that can simply be launched from another shell or program. Otherwise I could just run "guix shell -- eshell".

TO BE CONTINUED...

Copyright

This work © 2024 by Christopher Howard is licensed under Attribution-ShareAlike 4.0 International.

=> CC BY-SA 4.0 Deed

Proxy Information
Original URL
gemini://gem.librehacker.com/gemlog/starlog/20240924-0.gmi
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
868.780082 milliseconds
Gemini-to-HTML Time
0.399524 milliseconds

This content has been proxied by September (ba2dc).