-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmop.sh
executable file
·159 lines (143 loc) · 2.09 KB
/
mop.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
# https://github.com/dubniczky/Shell-Utilities
# Clean up common temporary files and folders in the current directory
# Check for help
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "Clean up common temporary files and folders in the current directory."
echo "Removes binaries, logs, archives, build files, other temporaries, and anything ingnored by git."
echo "It is recommended to run this in a git project, to avoid deleting files that are not tracked."
echo "Usage: mop"
exit 0
fi
globs=(
# General
logs
*.log
out
.temp
*.cache
dist
build
*.tmp
*.tmp.*
*.~*
coverage
.coverage
*.sqlite*
packages
*.zip
*.tar
*.tar.gz
*.tar.bz2
*.tar.xz
*.tgz
*.tbz2
*.txz
*.rar
*.7z
*.gz
# Nodejs
node_modules
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
.grunt
bower_components
jspm_packages
*.tsbuildinfo
.npm
.eslintcache
*.tgz
.yarn-integrity
.next
.nuxt
*.sass-cache
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.webpack
.expo
__generated__
# Python
__pycache__
.pytest_cache
.venv
.Python
*.py[cod]
*.egg-info
*.egg
*.ipynb_checkpoints
develop-eggs
eggs
MANIFEST
*.manifest
pip-log.txt
pip-delete-this-directory.txt
.pybuilder
ipython_config.py
__pypackages__
*.sage.py
.pyre
.pytype
# C/C++/C#
[Bb]uild
[Dd]ebug
obj
bin
lib
lib64
*.out
*.o
*.so
*.i
*.ii
*.obj
*.dylib
*.dll
*.exe
*.app
# Go
vendor
Godeps
go.work
*.exe-*
# Security
*.prv
*.key
*.pem
*.p12
*.crt
*.p8
*.pkcs12
# OS Specific
.DS_Store
.DS_Store?
Thumbs.db
.AppleDouble
.LSOverride
Icon
.Trashes
ehthumbs.db
._*
.TemporaryItems
.Spotlight-V100
.VolumeIcon.icns
)
# Remove items
removed_items=$(rm -rfv ${globs[@]} 2> /dev/null)
#echo $removed_items
# Count removed items
count="0"
if [ ! -z "$removed_items" ]; then
count=$(echo "$removed_items" | wc -l | xargs echo)
fi
# Remove other items ignored by git
if [ ! -z "$(command -v git)" ] && [ -f ".gitignore" ]; then
git_items=$(git clean -fdX 2> /dev/null)
if [ ! -z "$git_items" ]; then
git_count=$(echo "$git_items" | wc -l | xargs echo)
count=$((count+git_count))
fi
fi
# Print summary
echo "Removed $count items."