kleinpa kleinpa - 4 months ago 14x
Bash Question

Emacs shell-specific environment variables

In native emacs on windows, how can I specify environment variables for launching my shell inside emacs without modifying emacs' environment? In my specific case I'd like to set

to a cygwin-specific value for zsh without modifying where emacs thinks it's config file lives.

I've tried some things like changing my shell to
env -u HOME ...\zsh.exe
, but that seems to break
(it appeared to involve argument order).

If this command existed, it would probably do what I want:

(setq explicit-zsh-environment '("HOME" nil))

I've read a bunch of related questions like (How can I run Cygwin Bash Shell from within Emacs?), but the unusual part for me is that all my config files are cygwin-
-ed or windows-
-ed into a git repo and cygwin and windows take very different and incompatible approaches to symlinks.


Is this about running zsh as a shell inside Emacs (i.e. not about starting Emacs from a zsh shell), and having the environment that the inferior zsh process sees be different to the environment that Emacs has?

If so, you can bind the C-hv process-environment variable when you start a process. e.g.:

(let ((process-environment '("HOME=/tmp")))
  (call-interactively 'shell))
$ echo $HOME