You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You could imagine a more refined version of the following shell code that could query wt for current worktrunk state and only trigger the direnv allow based on a wt config.
post-switch is probably overkill since direnv allow only needs to happen once. I need to play around with this more. Ideally once the worktree is deleted, the direnv allow for that directory would also be cleaned up from whenever direnv stores its state.
@max-sixty mostly a security issue. once direnv is allowed to operate on a path prefix, any .envrc under that prefix can then load env vars and run arbitrary code in the .envrc file.
Activity
max-sixty commentedon Jan 18, 2026
thanks for the issue!
would be great to support this better. I don't use
direnvmyself so may need some guidance if I'm missing anything.would the
post-switchhook work well for this?...it runs after switching into the worktree, so the .envrc gets approved automatically. It can be a User Hook so it runs on all local projects?
strangemonad commentedon Jan 19, 2026
post-switch is probably overkill since
direnv allowonly needs to happen once. I need to play around with this more. Ideally once the worktree is deleted, the direnv allow for that directory would also be cleaned up from whenever direnv stores its state.max-sixty commentedon Jan 19, 2026
sorry, you're correct:
post-createorpost-startwould be better, and thenpre-removefor cleaning upI'm considering ways to make the hooks less verbose which will make this more discreet
how does that sound?
max-sixty commentedon Jan 19, 2026
thinking about it some more: what's the downside of the
whitelistoption?strangemonad commentedon Jan 19, 2026
@max-sixty mostly a security issue. once direnv is allowed to operate on a path prefix, any
.envrcunder that prefix can then load env vars and run arbitrary code in the.envrcfile.max-sixty commentedon Feb 10, 2026
the hooks are now much less verbose! it'll add just a couple of words to the output when running in the background.
so I think it makes sense to keep at that generic level. let me know how that goes, feel free to open a new issue if there are still issues