Created
May 1, 2016 10:30
-
-
Save a0s/29a58c8df6446a87c50ec035b2b5dfcd 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
#!ruby | |
# Requirements: | |
# brew install trash | |
casks_path = '/opt/homebrew-cask/Caskroom' | |
if `brew list | grep trash`.empty? | |
puts 'Please make "brew install trash" before' | |
exit! | |
end | |
Dir['/opt/homebrew-cask/Caskroom/*'].each do |program| | |
versions = Dir["#{program}/*"].map{|version| [File.ctime(version), version] } | |
next if versions.size == 1 | |
versions.sort! {|a,b| a[0]<=>b[0]} | |
puts "#{versions.pop[1]}" | |
versions.reverse.each do |_, version| | |
`trash #{version}` | |
puts "#{version} trashed" | |
end | |
end |
Author
a0s
commented
May 1, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment