diff options
| author | 2026-04-21 01:24:38 +0100 | |
|---|---|---|
| committer | 2026-04-21 01:24:38 +0100 | |
| commit | f8024b5097eb42119c9aa55ade98630df041f4f2 (patch) | |
| tree | 3b673c57c0743e7be4ab64972439557a9ee0bc08 /just-lib.sh | |
| parent | edc5e6070f23c02a45635a1e0180e998fd6c4fb2 (diff) | |
| download | dotfiles-f8024b5097eb42119c9aa55ade98630df041f4f2.tar.gz dotfiles-f8024b5097eb42119c9aa55ade98630df041f4f2.tar.bz2 dotfiles-f8024b5097eb42119c9aa55ade98630df041f4f2.zip | |
refactor(justfile): extract fmt/lint helpers into just-lib.sh; add doctor recipe
Diffstat (limited to 'just-lib.sh')
| -rw-r--r-- | just-lib.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/just-lib.sh b/just-lib.sh new file mode 100644 index 0000000..2392709 --- /dev/null +++ b/just-lib.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# shellcheck shell=bash +# Shared helpers for the fmt / check-fmt / lint just recipes. +# Sourced from justfile recipe bodies; not standalone. + +_need() { + command -v "$1" >/dev/null 2>&1 || { + printf 'error: %s not on PATH (install: %s)\n' "$1" "$2" >&2 + exit 1 + } +} + +_find_shells() { + find . -type f \ + \( -name '*.sh' \ + -o -path './dot_local/bin/executable_*' \ + -o -path './dot_config/sway/executable_*' \) \ + -not -path './.git/*' -not -path './.worktrees/*' +} + +_find_by_ext() { + find . -type f -name "*.$1" \ + -not -path './.git/*' -not -path './.worktrees/*' +} + +_find_zsh() { + find . -type f \ + \( -name 'dot_zshrc' -o -name 'dot_zshenv' -o -name 'dot_zprofile' \) \ + -not -path './.git/*' -not -path './.worktrees/*' +} + +_is_zsh() { + case "$(basename "$1")" in + dot_zshrc | dot_zshenv | dot_zprofile | .zshrc | .zshenv | .zprofile) return 0 ;; + esac + return 1 +} + +_is_shellscript() { + head -1 "$1" 2>/dev/null | grep -qE '^#!.*\b(ba)?sh\b' +} |
