Skip to content

Instantly share code, notes, and snippets.

@shreeve
Created December 1, 2015 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shreeve/c3f67b051091942e05de to your computer and use it in GitHub Desktop.
Save shreeve/c3f67b051091942e05de to your computer and use it in GitHub Desktop.
App Info (Mac OSX)
#!/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