I'm getting older. My memory and my wrists aren't as nimble as they once were.
When I do get a sliver of time to work on a personal project, it's nice to have a couple of project specific one-liners that I can run in my terminal to save me from the inevitable chore of re-reading the documentation of whatever build tool or process I want to use.
Just is a tool that supplements my aging brain wonderfully. It's essentially a command runner in the guise of a Makefile.
All I have to do is craft a small .justfile
in the root directory of a project, whilst the commands are all fresh in my mind. When I finally return to my project, I smash just -l
into my terminal and I'll be welcomed by a list of actions I can execute, based on the project I'm in.
Take this blog, for example. Do I remember the hugo new content…
command each year I pressure myself into writing a new blog post? Hell no!
I have a .justfile
for my blog, and after checking my usual actions with just
(no -l
needed for me, you'll see why), I'm reminded that I can run just post
followed by a post title to create a new blog post and open it in a text editor.
Here's my blog's .justfile
in all its glory:
# `just` override
:
# Serve the site on localhost
:
# Create a new blog post (titles-like-this)
:
# Start a tmux session
:
Here, there are four recipes, or actions as I sometimes call them. The _default
recipe means that I can use the just
command without the -l
to list my available actions. The serve
recipe simply gets my website running locally.
The post
recipe creates a new blog entry with a title that I provide at invocation (just post super-sexy-catchy-post-title
), wrangles that post into the directory structure that I like and then opens that new post in my text editor of the day.
Finally, the tmux
recipe spawns a new tmux session with two windows - one for activities and one for serving my website locally. It also cracks open a browser window, loading the locally hosted instance of my site. This is useful for when I might decide to work on my theme or site functionality.
Using this tool allows me to start being productive quickly, with less typing - saving my poor wrists from extraneous fatigue.
Here's an example of a .justfile
that I might use for in a directory that contains a number of dockerfiles:
# Variables for defaults
defaultFile :=
# `just` override
:
# Build a dockerfile
:
# Build and run a dockerfile
: # (Hidden) Build and Tag container image
: # Build, Tag and Push a container image
:
This one's a little more complex but it shows how you can chain recipes together. For example, the run
recipe will first run the build
recipe.
I won't go into much more detail here - hopefully you see how I find this utility useful. If you're interested in checking Just out, it's documentation is pretty thorough.