Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
add brew linkapps --system
Browse files Browse the repository at this point in the history
Added an option to linkapps to allow linking to /Applications rather
than ~/Applications

Closes #18196.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
  • Loading branch information
iainbeeston authored and adamv committed Mar 14, 2013
1 parent 2d18257 commit 65ccc39
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Library/Contributions/cmd/brew-linkapps.rb
@@ -1,11 +1,11 @@
# Links any Applications (.app) found in installed prefixes to ~/Applications
require "formula"

HOME_APPS = File.expand_path("~/Applications")
TARGET_DIR = ARGV.include?("--system") ? "/Applications" : File.expand_path("~/Applications")

unless File.exist? HOME_APPS
opoo "#{HOME_APPS} does not exist, stopping."
puts "Run `mkdir ~/Applications` first."
unless File.exist? TARGET_DIR
opoo "#{TARGET_DIR} does not exist, stopping."
puts "Run `mkdir #{TARGET_DIR}` first."
exit 1
end

Expand All @@ -17,17 +17,17 @@
Dir["#{f.installed_prefix}/*.app", "#{f.installed_prefix}/bin/*.app", "#{f.installed_prefix}/libexec/*.app"].each do |p|
puts "Linking #{p}"
appname = File.basename(p)
target = HOME_APPS+"/"+appname
target = TARGET_DIR+"/"+appname
if File.exist? target
if File.symlink? target
system "rm", target
else
onoe "#{target} already exists, skipping."
end
end
system "ln", "-s", p, HOME_APPS
system "ln", "-s", p, TARGET_DIR
end
end
end

puts "Finished linking. Find the links under ~/Applications."
puts "Finished linking. Find the links under #{TARGET_DIR}."

0 comments on commit 65ccc39

Please sign in to comment.