/
rules.sample.rb
75 lines (65 loc) · 2.46 KB
/
rules.sample.rb
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
# Sample Maid rules file -- some ideas to get you started.
#
# To use, remove ".sample" from the filename, and modify as desired. Test using:
#
# maid clean -n
#
# **NOTE:** It's recommended you just use this as a template; if you run these rules on your machine without knowing
# what they do, you might run into unwanted results!
#
# Don't forget, it's just Ruby! You can define custom methods and use them below:
#
# def magic(*)
# # ...
# end
#
# If you come up with some cool tools of your own, please send me a pull
# request on GitHub! Also, please consider sharing your rules with others via
# [the wiki](https://github.com/benjaminoakes/maid/wiki).
#
# For more help on Maid:
#
# * Run `maid help`
# * Read the README, tutorial, and documentation at https://github.com/benjaminoakes/maid#maid
# * Ask me a question over email (hello@benjaminoakes.com) or Twitter (@benjaminoakes)
# * Check out how others are using Maid in [the Maid wiki](https://github.com/benjaminoakes/maid/wiki)
Maid.rules do
# **NOTE:** It's recommended you just use this as a template; if you run these rules on your machine without knowing
# what they do, you might run into unwanted results!
rule 'Linux ISOs, etc' do
trash(dir('~/Downloads/*.iso'))
end
rule 'Linux applications in Debian packages' do
trash(dir('~/Downloads/*.deb'))
end
rule 'Mac OS X applications in disk images' do
trash(dir('~/Downloads/*.dmg'))
end
rule 'Mac OS X applications in zip files' do
found = dir('~/Downloads/*.zip').select do |path|
zipfile_contents(path).any? { |c| c.match(%r{\.app/Contents/}) }
end
trash(found)
end
rule 'Misc Screenshots' do
dir('~/Desktop/Screen shot *').each do |path|
move(path, '~/Documents/Misc Screenshots/') if 1.week.since?(accessed_at(path))
end
end
# NOTE: Currently, only Mac OS X supports `duration_s`.
rule 'MP3s likely to be music' do
dir('~/Downloads/*.mp3').each do |path|
move(path, '~/Music/iTunes/iTunes Media/Automatically Add to iTunes/') if duration_s(path) > 30.0
end
end
# NOTE: Currently, only Mac OS X supports `downloaded_from`.
rule 'Old files downloaded while developing/testing' do
dir('~/Downloads/*').each do |path|
next unless downloaded_from(path).any? do |u|
u.match('http://localhost') || u.match('http://staging\.yourcompany\.com')
end &&
1.week.since?(accessed_at(path))
trash(path)
end
end
end