aboutsummaryrefslogtreecommitdiff
path: root/clean.sh
blob: c15e201cd217b2fec4fed9257aae8938ea025018 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env bash
set -euxo pipefail

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