Skip to content

Instantly share code, notes, and snippets.

@sleexyz
Last active May 27, 2023 04:01
Show Gist options
  • Save sleexyz/4efa3da428b1e6c4856071b69385c97d to your computer and use it in GitHub Desktop.
Save sleexyz/4efa3da428b1e6c4856071b69385c97d to your computer and use it in GitHub Desktop.
helpers to recurse into subdirectories
list:
#!/usr/bin/env just _recurse bash
echo "$DIR":
just -l | tail -n +2
test: (_recurse_subcommand "test")
_recurse_subcommand command:
#!/usr/bin/env just _recurse bash
if [[ "$DIR" == "." ]]; then
exit 0
fi
if ! just -l | grep -q '{{command}}$'; then
exit 0
fi
echo "$DIR":
just {{command}} |& pr -to 4 # add indent
_recurse shell script_file:
#!/bin/bash
file_paths() {
ag -l -G 'Justfile$' . | sort
}
while IFS= read -r file_path; do
export DIR=$(dirname $file_path)
(cd $DIR && {{shell}} {{script_file}})
done <<< "$(file_paths)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment