Hacker News new | ask | show | jobs
by clhodapp 1180 days ago
Maybe your profile location ought to be something that you're able to set through chsh
2 comments

Huh. So I was about to disagree because that felt like a kludge, but actually you're right; setting your shell and its environment are both things that have to be set before the user's normal environment is working for bootstrapping reasons, so yeah, it does make perfect sense to cover both with the same mechanism. Or maybe to make it more generic we could replace the "shell" line in passwd with a "login command" entry, which is always executed by the system /bin/sh with the system environment from /etc/profile? Then you could set it to `XDG_CONFIG_HOME=$HOME/mydotfiles /bin/shell`, or `/bin/decrypt-my-home; export XDG_CONFIG_HOME=$HOME/Library/config; exec /bin/bash --init-file $HOME/Library/bash/bashrc` or whatever you want.
There is a system-wide /etc/profile or /etc/profile.d/

Likewise, zsh will look for /etc/zshrc

And zsh will actually look at

    $ZDOTDIR/.zshenv
    $ZDOTDIR/.zprofile
    $ZDOTDIR/.zshrc
    $ZDOTDIR/.zlogin
    $ZDOTDIR/.zlogout
So perhaps you can set the value of ZDOTDIR in one of the systemwide locations to use "$HOME/foo/bar/zsh/" and this way zsh will use ~/foo/bar/zsh/ as the location for the user specific .zshrc and other mentioned files for every user

https://eng.libretexts.org/Bookshelves/Computer_Science/Oper...

https://bash.cyberciti.biz/guide/Setting_system_wide_shell_o...

https://zsh.sourceforge.io/Intro/intro_3.html

Yep! On my real systems, my configured shell is a wrapper which sets ZDOTDIR and execs zsh from my nix profile.