purcell / envrc

Emacs support for direnv which operates buffer-locally
379 stars 35 forks source link

Add defvar envrc-venv-name #43

Closed doolio closed 2 years ago

doolio commented 2 years ago

Would it be possible to add a envrc-venv-name variable and ideally for its value to just be the pertinent part? That is say direnv exports VIRTUAL_ENV with a value of /home/doolio/projects/learning/python/atbs/.direnv/python-3.9.2 then envrc-venv-name would have the value python-3.9.2?

I'm hoping that I could then somehow add that information to my eshell prompt like I can do in a bash terminal.

Thanks for your time.

purcell commented 2 years ago

Nothing in envrc.el is specific to virtualenvs, so that's not really possible. I don't use eshell, but presumably the eshell prompt can run arbitrary elisp, so it could simply inspect (getenv "VIRTUAL_ENV") and extract the relevant part, e.g. using (file-name-nondirectory (getenv "VIRTUAL_ENV")).

doolio commented 2 years ago

I see. Your assumption about eshell is correct. Thanks for the snippet. It gives me something to work with.