Document creating user justfile recipe aliases (#1005)
This commit is contained in:
parent
9002478ad1
commit
16aa0ed34e
34
README.adoc
34
README.adoc
@ -1732,24 +1732,48 @@ A non-normative grammar of justfiles can be found in link:GRAMMAR.md[].
|
||||
|
||||
Before `just` was a fancy Rust program it was a tiny shell script that called `make`. You can find the old version in link:extras/just.sh[].
|
||||
|
||||
=== Non-Project Specific Justfile
|
||||
=== User Justfiles
|
||||
|
||||
If you want some commands to be available everywhere, put them in `~/.global.justfile` and add the following to your shell's initialization file:
|
||||
If you want some recipes to be available everywhere, you have a few options.
|
||||
|
||||
First, create a justfile in `~/.user.justfile` with some recipes.
|
||||
|
||||
==== Recipe Aliases
|
||||
|
||||
If you want to call the recipes in `~/.user.justfile` by name, and don't mind creating an alias for every recipe, add the following to your shell's initialization script:
|
||||
|
||||
```sh
|
||||
alias .j='just --justfile ~/.global.justfile --working-directory ~'
|
||||
for recipe in `just --justfile ~/.user.justfile --summary`; do
|
||||
alias $recipe="just --justfile ~/.user.justfile --working-directory . $recipe"
|
||||
done
|
||||
```
|
||||
|
||||
Or, if you'd rather they run in the current directory:
|
||||
Now, if you have a recipe called `foo` in `~/.user.justfile`, you can just type `foo` at the command line to run it.
|
||||
|
||||
It took me way too long to realize that you could create recipe aliases like this. Notwithstanding my tardiness, I am very pleased to bring you this major advance in justfile technology.
|
||||
|
||||
==== Forwarding Alias
|
||||
|
||||
If you'd rather not create aliases for every recipe, you can create a single alias:
|
||||
|
||||
```sh
|
||||
alias .j='just --justfile ~/.global.justfile --working-directory .'
|
||||
alias .j='just --justfile ~/.user.justfile --working-directory .'
|
||||
```
|
||||
|
||||
Now, if you have a recipe called `foo` in `~/.user.justfile`, you can just type `.j foo` at the command line to run it.
|
||||
|
||||
I'm pretty sure that nobody actually uses this feature, but it's there.
|
||||
|
||||
¯\\_(ツ)_/¯
|
||||
|
||||
==== Customization
|
||||
|
||||
You can customize the above aliases with additional options. For example, if you'd prefer to have the recipes in your justfile run in your home directory, instead of the current directory:
|
||||
|
||||
```sh
|
||||
alias .j='just --justfile ~/.user.justfile --working-directory ~'
|
||||
```
|
||||
|
||||
== Contributing
|
||||
|
||||
`just` welcomes your contributions! `just` is released under the maximally permissive https://creativecommons.org/publicdomain/zero/1.0/legalcode.txt[CC0] public domain dedication and fallback license, so your changes must also be released under this license.
|
||||
|
Loading…
Reference in New Issue
Block a user