Skip to content

Commit 80ec9cc

Browse files
author
Rafael Basask
committed
kkclean changes
1 parent e454b46 commit 80ec9cc

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

kkclean

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
11
#!/bin/bash
22

3+
CL_ERR="\e[31m"
4+
CL_OK="\e[32m"
5+
CL_RESET="\033[0m\e[0m"
6+
FMT_BOLD=$(tput bold)
7+
FMT_RESET=$(tput sgr0)
8+
9+
confirm () {
10+
read -r -p "${1:-Delete all files? [Y/n]} " choose
11+
case $choose in
12+
[Nn])
13+
false
14+
;;
15+
*)
16+
true
17+
;;
18+
esac
19+
}
20+
321
count=`find . -name *.pyc | wc -l`
422
if [ $count -gt 0 ]; then
523
find . -name "*.pyc" -delete
6-
echo "$count *.pyc deleted!"
24+
echo -e "${CL_OK}$count${CL_RESET}${FMT_BOLD} *.pyc deleted!${FMT_RESET}"
25+
else
26+
echo -e "${FMT_BOLD}No ${CL_OK}*.pyc${CL_RESET}${FMT_BOLD} files found.${FMT_RESET}"
727
fi
828

9-
count=`find . -name migrations | wc -l`
10-
if [ $count -gt 0 ]; then
11-
echo "$count migrations found!"
12-
echo "Choose [y/n] for each one to delete:"
13-
find . -name "migrations" -exec echo -n " " \; -ok rm -rf {} \;
29+
migrations=`find . -name migrations`
30+
if [ -n "$migrations" ]; then
31+
echo -e "${FMT_BOLD}The following dirs will be deleted:${FMT_RESET}"
32+
for mig in $migrations; do
33+
echo -e "\t$CL_ERR$mig$CL_RESET"
34+
done
35+
confirm "Delete all files? [Y/n]" && find . -name migrations -prune -exec rm -rf {} \;
36+
else
37+
echo -e "${FMT_BOLD}No ${CL_OK}migrations${CL_RESET}${FMT_BOLD} files found.${FMT_RESET}"
1438
fi

0 commit comments

Comments
 (0)