External command: brew linkapps
This command looks for Cocoa Applications (.app bundles) in the prefix of all installed formulae. If any are found, they are linked into "~/Applications", the system-defined location for per-user apps.
This commit is contained in:
parent
9f9219a142
commit
870ba9fa4b
28
Library/Contributions/examples/brew-linkapps.rb
Executable file
28
Library/Contributions/examples/brew-linkapps.rb
Executable file
@ -0,0 +1,28 @@
|
||||
# Links any Applications (.app) found in installed prefixes to ~/Applications
|
||||
require "formula"
|
||||
|
||||
unless File.exist? File.expand_path("~/Applications")
|
||||
opoo File.expand_path("~/Applications")+" does not exist, stopping."
|
||||
exit 1
|
||||
end
|
||||
|
||||
HOMEBREW_CELLAR.subdirs.each do |keg|
|
||||
next unless keg.subdirs
|
||||
name = keg.basename.to_s
|
||||
|
||||
if ((f = Formula.factory(name)).installed? rescue false)
|
||||
Dir["#{f.prefix}/*.app"].each do |p|
|
||||
puts "Linking #{p}"
|
||||
appname = File.basename(p)
|
||||
target = File.expand_path("~/Applications")+"/"+appname
|
||||
if File.exist? target
|
||||
if File.symlink? target
|
||||
system "rm", target
|
||||
else
|
||||
onoe "#{target} already exists, skipping."
|
||||
end
|
||||
end
|
||||
system "ln", "-s", p, File.expand_path("~/Applications")
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user