aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/justfile
diff options
context:
space:
mode:
authorLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-04-21 01:23:49 +0100
committerLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-04-21 01:23:49 +0100
commit619e0f6c7079c0e09b53a7532f9abc210650d4a0 (patch)
treed586943c500d9a3343d114a285c41b97bffa544c /justfile
parent0873b916d6d20972a7ce031b62906ef5d9ca567a (diff)
downloaddotfiles-619e0f6c7079c0e09b53a7532f9abc210650d4a0.tar.gz
dotfiles-619e0f6c7079c0e09b53a7532f9abc210650d4a0.tar.bz2
dotfiles-619e0f6c7079c0e09b53a7532f9abc210650d4a0.zip
feat(justfile): add etc-rm recipe
Removes one or more files from the repo's etc/ tree and tidies any now-empty parent directories (bounded to inside etc/). Leaves the live /etc copy untouched. Composes with etc-reset to stop tracking a file cleanly: just etc-reset /etc/foo.conf # repo → pristine just apply # deploy pristine to /etc just etc-rm etc/foo.conf # stop tracking; /etc unchanged
Diffstat (limited to 'justfile')
-rw-r--r--justfile23
1 files changed, 23 insertions, 0 deletions
diff --git a/justfile b/justfile
index 212730a..0094a12 100644
--- a/justfile
+++ b/justfile
@@ -334,6 +334,29 @@ etc-add +paths:
echo
echo "Run 'chezmoi apply' to sync (no-op content-wise, refreshes deploy hash)."
+# Remove one or more files from the repo's etc/ tree (leaves live /etc untouched)
+etc-rm +paths:
+ #!/usr/bin/env bash
+ set -eo pipefail
+ for raw in {{ paths }}; do
+ case "$raw" in
+ *..*|*/./*|./*|../*) echo "error: unsafe path: $raw" >&2; exit 1 ;;
+ esac
+ p=${raw#/}; p=${p#etc/}
+ repo=etc/$p
+ [ -f "$repo" ] || { echo "error: $repo is not managed in the repo" >&2; exit 1; }
+ rm -- "$repo"
+ # Tidy empty parent dirs inside etc/ without walking out of it
+ parent=$(dirname "$repo")
+ while [ "$parent" != "etc" ] && [ "$parent" != "." ]; do
+ rmdir -- "$parent" 2>/dev/null || break
+ parent=$(dirname "$parent")
+ done
+ echo "removed: $repo (/etc/$p left untouched)"
+ done
+ echo
+ echo "Run 'just apply' to refresh the deploy-etc hash."
+
# Reset repo-managed etc/<path> to pristine pacman contents (run 'just apply' afterward)
etc-reset +paths:
#!/usr/bin/env bash