Created
December 1, 2015 15:02
-
-
Save shreeve/c3f67b051091942e05de to your computer and use it in GitHub Desktop.
App Info (Mac OSX)
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
#!/usr/bin/ruby -E binary | |
# alias lscleanup="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder" | |
apps = {} | |
uses = {} | |
text = %x{`locate lsregister` -dump} | |
rows = text.split('-' * 80); rows.shift | |
rows.each do |data| | |
type = data[/^(\w+)\tid:/, 1] or next | |
info = Hash[*data.scan(/^\t([- \w]+): *(\S.*)$/).flatten] | |
case type | |
when "bundle", "plugin" | |
name = info['name' ] || info['identifier'] | |
vers = info['displayVersion'] || info['version'] | |
path = info['path' ] | |
time = File.stat(path).mtime.strftime('%Y-%m-%d %H:%M:%S') | |
slug = [name, vers, time, path].join('|') | |
apps[slug] ||= true | |
when "handler" | |
targ = info.delete("all roles") | |
base = uses[targ] ||= Hash.new {|k,v| k[v]={}} | |
info.each {|k,v| base[k][v] = 0} | |
end | |
end | |
puts "\nApplications:" | |
apps.keys.sort {|a,b| a.downcase <=> b.downcase}.each {|item| p item} | |
puts "\nHandlers:" | |
uses = Hash[*uses.sort.flatten] | |
uses.each {|k,v| puts "#{k} => #{v.inspect}"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment