\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{linux\_china} \pdfinfo{ /Title (justfile.pdf) /Creator (Cheatography) /Author (linux\_china) /Subject (Justfile Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{4B41A3} \definecolor{LightBackground}{HTML}{F3F3F9} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Justfile Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{linux\_china} via \textcolor{DarkBackground}{\uline{cheatography.com/141366/cs/30282/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}linux\_china \\ \uline{cheatography.com/linux-china} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 22nd December, 2021.\\ Updated 7th April, 2024.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Simple justfile}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\#!/usr/bin/env just -{}-justfile \newline \newline \# hello is recipe's name \newline hello: \newline echo "Hello World!"} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{default Recipe}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{default: lint build test \newline \newline \# default recipe to display help information \newline default: \newline @just -{}-list \newline \newline \# {\bf{if no default recipe, first recipe will be default}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Aliases}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{alias t := test \newline alias c := check} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Settings}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{set shell := {[}"zsh", "-cu"{]} \newline \#set shell := {[}"bun", "exec"{]} \newline \newline \newline set dotenv-load := true \newline serv: \newline echo "\$DATABASE\_ADDRESS from .env" \newline \newline set positional-arguments := true \newline foo: \newline echo \$0 \newline echo \$1} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Strings - escape with Double-quoted}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{string-with-tab := "\textbackslash{}t" \newline string-with-newline := "\textbackslash{}n" \newline escapes := '\textbackslash{}t\textbackslash{}n\textbackslash{}r\textbackslash{}"\textbackslash{}\textbackslash{}' \newline \newline \# this string will evaluate to \textbackslash{}`foo\textbackslash{}nbar\textbackslash{}n\textbackslash{}` \newline x := ''' \newline foo \newline bar \newline '''} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{just command line}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{\# run recipe \newline % Row Count 1 (+ 1) \$ just hello param1 \newline % Row Count 2 (+ 1) \# list recipes in alphabetical order \newline % Row Count 3 (+ 1) \$ just -{}-list \newline % Row Count 4 (+ 1) \$ just -{}-summary \newline % Row Count 5 (+ 1) \# Show full information about recipe \newline % Row Count 6 (+ 1) just -{}-show test \newline % Row Count 7 (+ 1) \# select recipes to run interactively \newline % Row Count 8 (+ 1) \$ just -{}-choose \newline % Row Count 9 (+ 1) \# shell completion \newline % Row Count 10 (+ 1) just -{}-completions zsh% Row Count 11 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{GitHub Actions}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{- uses: \seqsplit{extractions/setup-just@v1} \newline with: \newline just-version: 0.10.5} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{IDE integration}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{VS Code: \seqsplit{https://marketplace.visualstudio.com/items?itemName=skellock.just}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{JetBrains: \seqsplit{https://plugins.jetbrains.com/plugin/18658-just}} \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Just module}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\# load bar/justfile, bar/.justfile, bar.just \newline mod bar} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{just -{}-unstable bar::hello} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Recipe with parameters}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{filter PATTERN: \newline echo \{\{PATTERN\}\} \newline \newline \# param with default value \newline email \seqsplit{address='master@example.com':} \newline echo \{\{address\}\} \newline \newline \# param with expression \newline test triple=(arch() + "-unknown-unknown"): \newline ./test \{\{triple\}\} \newline \newline \# variadic param: '+' aceept one or more values \newline backup +FILES: \newline scp \{\{FILES\}\} me@example.com \newline \newline \# variadic param with {\emph{: zero or more values \newline commit MESSAGE }}FLAGS: \newline git commit \{\{FLAGS\}\} -m "\{\{MESSAGE\}\}"} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Recipe with env variable for command}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\# recipe param as env variable with \$ sign \newline hello \$name: \newline echo \$name} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Recipe Dependencies - Before, After \& Around}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\# execution sequence: a -\textgreater{} b -\textgreater{} c -\textgreater{} d \newline b: a \&\& c d \newline \newline \# execute recipe 'a' around \newline b: \newline echo 'B start!' \newline just a \newline echo 'B end!' \newline \newline \# depend with params by expression \newline default: (build "main") \newline \newline build target: \newline @echo 'Building \{\{target\}\}...'} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Command annotate: quiet(@), suppress(-), invert(!)}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{hello: \newline @ echo "command will not be echoed" \newline - echo "ignore none-zero exit status and continue" \newline \newline @hello2: \newline echo "command will not be echoed" \newline \newline \# Invert command exit status by ! - shell feature \newline hello3: \newline \# if command succeeds(exit status is 0), exit just \newline ! git branch | grep '* master'} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Recipe with other Languages}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{bash-test: \newline \#!/usr/bin/env bash \newline set -euxo pipefail \newline hello='Yo' \newline echo "\$hello from bash!"} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Private Recipes - name starts with \_}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{test: \_test-helper \newline ./bin/test \newline \newline \# ommited from 'just -{}-list' \newline \_test-helper: \newline \seqsplit{./bin/super-secret-test-helper-stuff}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Recipes as shell alias}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{for recipe in \textbackslash{}`just -f \textasciitilde{}/.justfile -{}-summary\textbackslash{}`; do \newline alias \$recipe="just -f \textasciitilde{}/.justfile -d. \$recipe" \newline done} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Recipe with Python venv}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{venv: \newline {[} -d .venv {]} || uv venv \newline \newline run: venv \newline ./.venv/bin/python3 main.py} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Variable and Substitution}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{version := "0.2.7" \newline tardir := "awesomesauce-" + version \newline tarball := tardir + ".tar.gz" \newline \newline test: \newline echo \{\{version\}\} \newline \newline \# set/override variables from just command line \newline \$ just -{}-set version 1.1.0} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Environment variable for commands}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{export RUST\_BACKTRACE := "1" \newline \newline test: \newline \# will print a stack trace if it crashes \newline cargo test} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{backtick - capture output from evaluation}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{JAVA\_HOME := \textbackslash{}`jbang jdk home 11\textbackslash{}` \newline \# backtick code block \newline stuff := \textbackslash{}`\textbackslash{}`\textbackslash{}` \newline foo="hello" \newline echo \$foo "world" \newline \textbackslash{}`\textbackslash{}`\textbackslash{}` \newline \newline done BRANCH=\textbackslash{}`git rev-parse -{}-abbrev-ref HEAD\textbackslash{}`: \newline git checkout master \newline \newline sloc: \newline @echo "\textbackslash{}`wc -l *.c\textbackslash{}` lines of code" \newline \newline \# {\bf{backtick works anywhere: string/variable/params}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Just functions}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{hello name: \newline echo \{\{os()\}\} \newline echo \{\{uppercase(name)\}\} \newline \newline \# function categories \newline {\emph{ System Information \newline }} Environment Variables \newline {\emph{ Justfile and Justfile Directory \newline }} String Manipulation \newline * Path Manipulation \newline \newline \# String contact: (key + ":" + value)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Conditional expressions: if, loop and while}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\# regular expression match \newline fo := if "hi" =\textasciitilde{} 'h.+' \{ "match" \} else \{ "mismatch" \} \newline \newline test: \newline if true; then echo 'True!'; fi \newline for file in \textbackslash{}`ls .\textbackslash{}`; do echo \$file; done \newline while \textbackslash{}`server-is-dead\textbackslash{}`; do ping -c 1 server; done \newline \newline foo bar: \newline echo \{\{ if bar == "bar" \{ "hello" \} else \{ "bye" \} \}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Attention}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\# Each command line is executed by a new shell. \newline \# If a command line failed, just will exit, \textbackslash{} \newline \# and subsequent command lines will not be executed. \newline change-working-dir: \newline cd bar \&\& pwd \newline \# multi-line construct - escape newline with slash \newline if true; then \textbackslash{} \newline echo 'True!'; \textbackslash{} \newline fi \newline \newline \# justfile is case insensitive: Justfile, JUSTFILE etc \newline \# justfile could be hidden: '.justfile' \newline \# Call recipe from sub dir: \textbackslash{}`\textasciitilde{}/app1/target\textgreater{}\$ just build\textbackslash{}`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}