blob: aa1317b9d8034c9185ffb3b2bdd9d860867b9a7a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/bin/bash
# Copyright 2014 Red Hat, Inc.
# Part of clufter project
# Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt)
prefix="$(git rev-parse --show-prefix)"
grep_prefix="${prefix}"
[ -n "${grep_prefix}" ] || grep_prefix="[^#!]"
sed -n '/# KEEP/q;p' \
"$(git rev-parse --show-cdup).gitignore" \
| grep \
-e "^/\?${grep_prefix}" \
-e "^[^/#!]+$" \
| sed "s|^/\?${prefix}||" \
| while read file; do [[ "${file}" =~ [*?].* ]] \
&& find -name "${file}" \
|| echo "${file}"; \
done \
| xargs -- sh -c 'ls -1d $@ 2>/dev/null' sh \
| tee >(xargs -r -- sh -c 'ls --color -d "$@"' sh >&2) \
| xargs -r -- sh -c 'rm -Ir -- "$@" </dev/tty' sh
#| tee /dev/stderr \
# ^
# +-- using this instead of tee >(xargs ...) means one can use plain /bin/sh
|