psibi / justl.el

Major mode for driving just files.
GNU General Public License v3.0
65 stars 13 forks source link

Support running justl from a different directory #42

Open glucas opened 1 year ago

glucas commented 1 year ago

Executing commands from the justl buffer always runs in the justfile directory. This is not always desirable. For example, just supports [no-cd] to run recipes from the working directory instead of the justfile directory. This can be useful when working with projects that have multiple submodules with a common set of commands.

[no-cd]
test:
    pwd

One can use justl-exec-recipe-in-dir, but it would nice if there were a way to set the default directory for the justl buffer to drive recipes in a particular project directory.

psibi commented 1 year ago

You can use the variable justl-justfile to set a custom default directory: https://github.com/psibi/justl.el/blob/8821feee1a5e541af9cf1962877c817f07bbba21/justl.el#L98

glucas commented 1 year ago

That's different though -- that identifies which justfile to use, right?

I'm thinking of a case like this:

some-project/
   justfile
   module-1/
   module-2/

There's only one justfile, but it defines [no-cd] recipes that are useful in both module-1 and module-2. Right now if I'm working in module-1 and open the justl buffer those recipes fail since they run from the root dir instead. (But opening a shell and running just from the module-1 dir works fine.)

psibi commented 1 year ago

I see what you mean.

One can use justl-exec-recipe-in-dir, but it would nice if there were a way to set the default directory for the justl buffer to drive recipes in a particular project directory.

I'm open to PR's for this for changing the default working directory from the opened justl buffer.