Those few recipes illustrate the logic of using bacon, and may serve as inspiration for your own practices.

Tell me about your recipes so that I may share them there.

Jump to the next location in neovim

With the nvim-bacon plugin, you can navigate between errors and warnings without leaving nvim, just hitting a key.

Open your lib's doc

Let's first assume your bacon.toml file has been generated by a recent version of bacon.

Then you can launch bacon on its default task, then when you want to check the doc, hit the d key: as soon as the doc compiles, it's opened in your browser and bacon switches back to the previous job.

If you want to complete an old bacon.toml file, or just understand how it works, here's the relevant configuration:

The job:

[jobs.doc-open]
command = ["cargo", "doc", "--color", "always", "--no-deps", "--open"]
need_stdout = false
on_success = "back" # so that we don't open the browser at each change

And the key binding:

[keybindings]
d = "job:doc-open"

Configure Clippy lints

The jobs in the bacon.toml file are specific to your projects, there's no reason not to adapt them for its specificities.

You may for example want to tune the clippy rules:

[jobs.clippy]
command = [
    "cargo", "clippy",
    "--color", "always",
    "--",
    "-A", "clippy::collapsible_else_if",
    "-A", "clippy::collapsible_if",
    "-A", "clippy::field_reassign_with_default",
    "-A", "clippy::match_like_matches_macro",
]
need_stdout = false

Check for other platforms

You may define specific jobs for specific targets:

[jobs.check-win]
command = ["cargo", "check", "--target", "x86_64-pc-windows-gnu", "--color", "always"]

An habit I suggest: use alt keybindings for alternative platforms:

[keybindings]
alt-w = "job:check-win"

Run binaries and examples

If you configure a cargo run job, you'll get the usual warnings and errors until there's none, at which point you'll have the output of your binary (assuming its terminal output is interesting).

[jobs.exs]
command = ["cargo", "run", "--example", "simple", "--color", "always"]
allow_warnings = true
need_stdout = true

You may add on_success = "back" if you don't want the executable to run again on changes.

The allow_warnings = true line tells bacon to run the executable even when there are warnings. The excutable's output would come below warnings.

Some libraries and programs test whether they run in a TTY and remove style in such case. Most usually, those applications provide a way to bypass this test with a launch argument. Depending on the desired output, you would have to add a setting to the run job, for example (more on this):

command = ["cargo", "run", "--color", "always", "--", "--color", "yes"]

Variable arguments

Launch arguments after the -- aren't interpreted by bacon but sent inchanged to the job commands.

This may be useful to add an argument only for one run without changing the bacon.toml file.

For example

bacon -- --target x86_64-pc-windows-gnu

Be careful that some programs already require -- so you may have to double it. For example, to run cargo test with a single thread, you'll need

bacon test -- -- --test-threads=1

Another use case, a job which needs a complementary argument:

[jobs.ex]
command = ["cargo", "run", "--color", "always", "--example"]
need_stdout = true

You would call it with

bacon ex -- example4578