Settings
Settings control interpretation and execution. Each setting may be specified at
most once, anywhere in the justfile
.
For example:
set shell := ["zsh", "-cu"]
foo:
# this line will be run as `zsh -cu 'ls **/*.txt'`
ls **/*.txt
Table of Settings
Name | Value | Default | Description |
---|---|---|---|
allow-duplicate-recipes | boolean | false | Allow recipes appearing later in a justfile to override earlier recipes with the same name. |
dotenv-filename | string | - | Load a .env file with a custom name, if present. |
dotenv-load | boolean | false | Load a .env file, if present. |
dotenv-path | string | - | Load a .env file from a custom path, if present. Overrides dotenv-filename . |
export | boolean | false | Export all variables as environment variables. |
fallback | boolean | false | Search justfile in parent directory if the first recipe on the command line is not found. |
ignore-comments | boolean | false | Ignore recipe lines beginning with # . |
positional-arguments | boolean | false | Pass positional arguments. |
shell | [COMMAND, ARGS…] | - | Set the command used to invoke recipes and evaluate backticks. |
tempdir | string | - | Create temporary directories in tempdir instead of the system default temporary directory. |
windows-powershell | boolean | false | Use PowerShell on Windows as default shell. (Deprecated. Use windows-shell instead. |
windows-shell | [COMMAND, ARGS…] | - | Set the command used to invoke recipes and evaluate backticks. |
Boolean settings can be written as:
set NAME
Which is equivalent to:
set NAME := true
Allow Duplicate Recipes
If allow-duplicate-recipes
is set to true
, defining multiple recipes with
the same name is not an error and the last definition is used. Defaults to
false
.
set allow-duplicate-recipes
@foo:
echo foo
@foo:
echo bar
$ just foo
bar
Dotenv Settings
If dotenv-load
, dotenv-filename
or dotenv-path
is set, just
will load
environment variables from a file.
If dotenv-path
is set, just
will look for a file at the given path.
Otherwise, just
looks for a file named .env
by default, unless
dotenv-filename
set, in which case the value of dotenv-filename
is used.
This file can be located in the same directory as your justfile
or in a
parent directory.
The loaded variables are environment variables, not just
variables, and so
must be accessed using $VARIABLE_NAME
in recipes and backticks.
For example, if your .env
file contains:
# a comment, will be ignored
DATABASE_ADDRESS=localhost:6379
SERVER_PORT=1337
And your justfile
contains:
set dotenv-load
serve:
@echo "Starting server with database $DATABASE_ADDRESS on port $SERVER_PORT…"
./server --database $DATABASE_ADDRESS --port $SERVER_PORT
just serve
will output:
$ just serve
Starting server with database localhost:6379 on port 1337…
./server --database $DATABASE_ADDRESS --port $SERVER_PORT
Export
The export
setting causes all just
variables to be exported as environment
variables. Defaults to false
.
set export
a := "hello"
@foo b:
echo $a
echo $b
$ just foo goodbye
hello
goodbye
Positional Arguments
If positional-arguments
is true
, recipe arguments will be passed as
positional arguments to commands. For linewise recipes, argument $0
will be
the name of the recipe.
For example, running this recipe:
set positional-arguments
@foo bar:
echo $0
echo $1
Will produce the following output:
$ just foo hello
foo
hello
When using an sh
-compatible shell, such as bash
or zsh
, $@
expands to
the positional arguments given to the recipe, starting from one. When used
within double quotes as "$@"
, arguments including whitespace will be passed
on as if they were double-quoted. That is, "$@"
is equivalent to "$1" "$2"
…
When there are no positional parameters, "$@"
and $@
expand to nothing
(i.e., they are removed).
This example recipe will print arguments one by one on separate lines:
set positional-arguments
@test *args='':
bash -c 'while (( "$#" )); do echo - $1; shift; done' -- "$@"
Running it with two arguments:
$ just test foo "bar baz"
- foo
- bar baz
Shell
The shell
setting controls the command used to invoke recipe lines and
backticks. Shebang recipes are unaffected.
# use python3 to execute recipe lines and backticks
set shell := ["python3", "-c"]
# use print to capture result of evaluation
foos := `print("foo" * 4)`
foo:
print("Snake snake snake snake.")
print("{{foos}}")
just
passes the command to be executed as an argument. Many shells will need
an additional flag, often -c
, to make them evaluate the first argument.
Windows Shell
just
uses sh
on Windows by default. To use a different shell on Windows,
use windows-shell
:
set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
hello:
Write-Host "Hello, world!"
See powershell.just for a justfile that uses PowerShell on all platforms.
Windows PowerShell
set windows-powershell
uses the legacy powershell.exe
binary, and is no
longer recommended. See the windows-shell
setting above for a more flexible
way to control which shell is used on Windows.
just
uses sh
on Windows by default. To use powershell.exe
instead, set
windows-powershell
to true.
set windows-powershell := true
hello:
Write-Host "Hello, world!"
Python 3
set shell := ["python3", "-c"]
Bash
set shell := ["bash", "-uc"]
Z Shell
set shell := ["zsh", "-uc"]
Fish
set shell := ["fish", "-c"]
Nushell
set shell := ["nu", "-c"]
If you want to change the default table mode to light
:
set shell := ['nu', '-m', 'light', '-c']
Nushell was written in Rust, and has cross-platform support for Windows / macOS and Linux.