hyperupcall / autoenv

Directory-based environments.
MIT License
5.72k stars 261 forks source link

Source parent directory's `.env.leave` file when leaving subdirectory #236

Open chrysle opened 6 months ago

chrysle commented 6 months ago

First of all, thanks for this handy tool!

Is your feature request related to a problem? Please describe.

I have a directory containing multiple Git repositories and a .env file. Now, whenever I cd into one of these subdirectories, the parent's .env file is executed, as intended, and activates a virtual environment it searches in another directory. Now, in the same folder I configured a .env.leave file to deactivate such an environment once I leave it again. However, when I leave the folder, the .env.leave is not sourced – which I find a bit odd, considering that parental .env files are when entering.

Describe the solution you'd like

I'd like to have a .env.leave file executed whenever I leave a subdirectory of the directory where it is residing (and the same) – probably only depth 1, or to be configured.

Describe alternatives you've considered

Deactivating manually. It isn't a big deal, or copying a similar .env.leave file into each of my repositories – it would be slightly suboptimal though, for I'd have to tell Git to not bother about this "untracked change".

Additional context