logoalt Hacker News

mongol12/08/20243 repliesview on HN

I use direnv but miss that it can't initialize bash completions as I enter a directory. Can mise do that?


Replies

jdxcode12/08/2024

there isn't a hook for executing shell source, but it would be possible to add I think. The current hooks already execute inside of a shell function so there would just need to be a way to declare that you want a hook to run inside the shell, maybe like this:

    [hooks.enter]
    shell = true
    run = ". completions/mycli.sh"
I made an issue if you'd like to track: https://github.com/jdx/mise/issues/3412
show 1 reply
ghthor12/08/2024

Direnv can do this, but currently only for bash shells and maybe only when using nix flakes. There is an open issue to get zsh working, but I just stick to bash TBH

show 1 reply
0xbadcafebee12/08/2024

I don't really understand why people use direnv, but you could easily replace it with a shell script that could load anything you want when entering a directory.

You basically just write a script that hooks into your shell (using your shell's existing hooks, like PROMPT_COMMAND for bash) and have it load a shell script in any directory you enter.

Obviously this is a security risk, as you could enter a directory controlled by a hacker. This is why (presumably) they only deal with exported variables, though even that's dangerous.

show 2 replies