Web lists-archives.com

Re: The same environment variables everywhere

Le nonidi 9 ventôse, an CCXXV, Teemu Likonen a écrit :
> I moved my variable assignments to ~/.environment.sh and source that to
> ~/.profile and ~/.xsession.

Zsh has a ~/.zshenv that is meant exactly for that. It is sourced by all
zsh instances, even those started as interpreters. It is very
convenient. I just have to make sure that ~/.xsession is a #!/bin/zsh
script, and it automatically gets the environment.

I start mine with:

[[ "$ZSHENV_USER" == $UID-1 ]] && return

That way, I avoid re-sourcing the file if it has already been sourced by
an ancestor. Thus, I can change the environment of a subtree of
processes without having it overridden, but the environment is
re-sourced if I ever use su. The "-1" can be changed to force
re-sourcing the file by new shells, but I do not use it anymore.

I do not know what shell systemd uses to start user programs: the user's
login shell or /bin/sh. If it is the former, then it works for that case


  Nicolas George

Attachment: signature.asc
Description: Digital signature