diff options
| author | Adam Vandenberg | 2010-06-09 12:09:34 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2010-06-09 13:53:50 -0700 |
| commit | c8e76dcc7b440616a2cfd9581145af41e875cc0e (patch) | |
| tree | a5afd724386daa4b4b7a7002e98a2eaf9fdda513 /Library | |
| parent | 324322a924f9ea28ed501c2e77abbdcd1530983b (diff) | |
| download | homebrew-c8e76dcc7b440616a2cfd9581145af41e875cc0e.tar.bz2 | |
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.
Diffstat (limited to 'Library')
| -rwxr-xr-x | Library/Contributions/examples/brew-linkapps.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Library/Contributions/examples/brew-linkapps.rb b/Library/Contributions/examples/brew-linkapps.rb new file mode 100755 index 000000000..bcaf7a9e3 --- /dev/null +++ b/Library/Contributions/examples/brew-linkapps.rb @@ -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 |
