MayCXC / envy

stackable and composable sh profiles.
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Q: layered envs & dynamic modifications? #1

Open akavel opened 1 month ago

akavel commented 1 month ago

Hi! I arrived here via your comment and mention on: https://github.com/oils-for-unix/oils/issues/880. I tried to understand the readme of "envy" in context of the topic I opened there, but unfortunately I failed for now, I'm afraid I'm super confused by what's described there, and how it can apply to what I'm interested in.

Could you possibly help me to try and understand how "envy" could work for me on an example use-case, and how I could specifically configure and use it in it? I will try to describe something I have on my mind to at least bootstrap a conversation:

I'm specifically interested in working in an interactive shell (the one most familar to me is bash). Let's say my PATH variable in my .bashrc/.bash_profile is built out from a system-global /etc/bashrc, with some addition done locally in .bashrc itself, as well as further tweaks by some extra/thirdparty helper script, called from within .bashrc. Then, in my interactive shell, I manually source'd yet another script, modifying the PATH env var further. Now, I would like to "dynamically" change how one of the middle layers (say, the line in .bashrc) modifies PATH from now on - having this change be applied to my current interactive bash session without having to restart it. Can envy help me achieve that? If yes, could you help me understand what specific bash lines I should try using to achieve that? Thanks!

MayCXC commented 1 month ago

yes, well, it does restart your shell, but with a single command:

./env.sh:

PATH="x/y/z:${PATH}"
envs ./path/to/helper/env.sh

helper/env.sh:

PATH="more:changes:${PATH}"

then you would start an interactive shell with: envy ./env.sh

you can edit either file, and run envz to see the changes reflected in your interactive shell. this uses posix sh, but I can add support for bash and other posix compliant shells.

MayCXC commented 1 month ago

in your case, could the same be accomplished by exec bash? envy is more useful to make the source path between scripts relative to their own parent directory.