Created
October 14, 2009 21:11
-
-
Save willb/210416 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Run git-tidy instead of "git clean" to keep from shooting yourself | |
# in the foot. Use "-i" to examine each file to be deleted. | |
function noninteractive() { | |
git clean -n | grep "Would remove" | |
echo | |
echo -n "Really delete the preceding files? (yes/no) " | |
while read input ; do | |
case "$input" in | |
yes) git clean ; exit ;; | |
YES) git clean ; exit ;; | |
no) exit;; | |
NO) exit;; | |
esac | |
echo 'Please enter "yes" or "no"' | |
echo -n "Really delete the preceding files? (yes/no) " | |
done | |
} | |
function interactive() { | |
git clean -n | grep "Would remove" | cut -c14- | tr \\n \\0 | xargs --null --interactive -L 1 rm | |
} | |
if [ "x$1" = "x-i" ] ; then | |
interactive | |
else | |
noninteractive | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment