mise hooks
I've written before about having a standardized set of commands across all my projects. One of the things that helps with that is mise hooks.
I've actually been migrating from justfiles to mise tasks over the past few months. mise already manages my tool versions, so consolidating task running into the same tool means one less thing to install and one less config file per project. The syntax is nearly identical—you're just writing shell commands with some metadata—and mise tasks have a few nice extras like file watching and automatic parallelization.
mise has a handful of lifecycle hooks that you can use to run arbitrary scripts at various points:
| Hook | When it runs |
|---|---|
cd |
Every time you change directories |
enter |
When you first enter a project directory |
leave |
When you leave a project directory |
preinstall |
Before a tool is installed |
postinstall |
After a tool is installed |
I am not a fan of injecting scripts into things that you want to be as fast as humanly possible, but here's one exception: I use the enter hook to print a little welcome message when I cd into a project:
[hooks]
enter = "echo 'bun dev — start dev server'"
This is a small thing, but it's a nice reminder of what commands are available when I'm jumping between projects. I'm always context-switching and I never remember what the right incantation is for any given project. This way, I get a little cheat sheet every time I enter a directory.