summaryrefslogtreecommitdiff
path: root/clean.sh
diff options
context:
space:
mode:
authorNathan Ringo <nathan@remexre.com>2024-02-26 00:46:09 -0600
committerNathan Ringo <nathan@remexre.com>2024-02-26 00:46:09 -0600
commitfec505240f22065aaea2ee80c1082cad136559bb (patch)
treec5154ef52e8792b9470957332caeedb925604012 /clean.sh
Initial commitHEADtrunk
Diffstat (limited to 'clean.sh')
-rwxr-xr-xclean.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/clean.sh b/clean.sh
new file mode 100755
index 0000000..68769e6
--- /dev/null
+++ b/clean.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+set -eu
+
+cd "$(git rev-parse --show-toplevel)"
+
+if [ "$(git status --porcelain=v1 --ignored -z | grep -z '^!!' | wc -c)" = 0 ]; then
+ exit
+fi
+
+git status --porcelain=v1 --ignored -z \
+| grep -z '^!!' \
+| xargs -0 awk 'BEGIN { for(i = 1; i < ARGC; i++) printf "%s%c", substr(ARGV[i], 4), 0; }' \
+| xargs -0 rm -r