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

Add --system option to brew linkapps #18196

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Library/Contributions/cmd/brew-linkapps.rb
Original file line number Diff line number Diff line change
@@ -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}."