-
Notifications
You must be signed in to change notification settings - Fork 0
/
rmshit.py
executable file
·87 lines (73 loc) · 1.7 KB
/
rmshit.py
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
#! /usr/bin/env python3
import os
import sys
import shutil
shittyfiles = [
'~/.bash_history',
'~/Desktop', # Firefox creates this
'~/.thumbnails',
'~/.gconfd',
'~/.gconf',
'~/.gstreamer-0.10',
'~/.pulse',
'~/.dbus',
'~/.nv/',
'~/.npm/', # npm cache
'~/.nvimlog',
'~/.java/',
'~/.oracle_jre_usage/',
'~/.cmake/',
'~/.subversion/',
'~/.lesshst',
'~/.cargo/',
'~/.cache/',
'~/.python_history',
'~/.config/enchant',
'~/.config/QtProject.conf',
'~/.config/dconf/',
'~/.config/nvim/.netrwhist',
'~/pandoc.out',
'~/.pkg-cache/',
'~/.wget-hsts',
'~/.dotnet/',
'~/.nuget/',
'~/.yarnrc',
'~/.yarn/',
'~/.pkg-cache',
'~/.tree-sitter/',
'~/.texlive/',
'~/.zoom/'
]
def yesno(question, default="n"):
""" Asks the user for YES or NO, always case insensitive.
Returns True for YES and False for NO.
"""
prompt = "%s (y/[n]) " % question
ans = input(prompt).strip().lower()
if not ans:
ans = default
if ans == "y":
return True
return False
def rmshit():
print("Found shittyfiles:")
found = []
for f in shittyfiles:
absf = os.path.expanduser(f)
if os.path.exists(absf):
found.append(absf)
print(" %s" % f)
if len(found) == 0:
print("No shitty files found :)")
return
if yesno("Remove all?", default="n"):
for f in found:
if os.path.isfile(f):
os.remove(f)
else:
shutil.rmtree(f)
print("All cleaned")
else:
print("No file removed")
if __name__ == '__main__':
rmshit()