Skip to content

Instantly share code, notes, and snippets.

@havenwood havenwood/foliage.rb
Created Apr 24, 2018

What would you like to do?
Sort your directly-installed homebrew packages by most recently run executable.
# frozen_string_literal: true
require 'date'
leaves = `brew leaves`.lines chomp: true
recent_bins = do |leaf|
bins = Dir[File.join `brew --cellar #{leaf}`.chomp, '*', 'bin', '*']
recently_used = bins.max_by { |bin| File.atime bin }
next unless recently_used
[leaf, File.basename(recently_used), File.atime(recently_used)]
recent_bins_sorted = recent_bins.sort_by { |_, _, time| time }.reverse
recent_bins_sorted.each do |leaf, bin, time|
puts "#{leaf}: `#{bin}` last run #{time.to_date}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.