Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recipe annotation to prevent cd-ing to justfile #762

Closed
casey opened this issue Mar 21, 2021 · 4 comments · Fixed by #1400
Closed

Add recipe annotation to prevent cd-ing to justfile #762

casey opened this issue Mar 21, 2021 · 4 comments · Fixed by #1400

Comments

@casey
Copy link
Owner

casey commented Mar 21, 2021

Proposed along with a few other features in #761, moving into its own issue to track separately.

It might be nice to have a recipe annotation that makes just use the invocation directory as the current working directory for that recipe, like so:

#[no_cd]
foo:
  pwd # will print invocation directory, not justfile directory
@tcassaert
Copy link

Until this is implemented, you can add

#!/usr/bin/env bash
cd -

which will take you back to the directory where you executed the just command.

@casey
Copy link
Owner Author

casey commented Sep 1, 2022

I can't get this to work:

foo:
  #!/usr/bin/env bash
  pwd
  cd -
  pwd
$ just foo
/Users/rodarmor/tmp/cd
/var/folders/b5/q2c4mxk534v6kwdtx2mpw91m0000gn/T/justF2cWhz/foo: line 4: cd: OLDPWD not set
/Users/rodarmor/tmp/cd

@tcassaert
Copy link

Hmmm, I can only get it to work when my Justfile is located in $HOME/Justfile. Didn't pay attention to that...

@casey casey linked a pull request Nov 3, 2022 that will close this issue
@casey
Copy link
Owner Author

casey commented Nov 3, 2022

We have recipe attributes now, so this was very simple to implement. It's available on master if you want to give it a shot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants