aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorTeo Ljungberg2013-09-21 17:11:25 +0200
committerAdam Vandenberg2013-10-29 21:04:25 -0700
commit95305e6256c73f1e19d7a71c6906a80c69e7c5c8 (patch)
treef4e4bd9dd43281dba18b09913d91a6e8f14df4b6 /Library
parent076df32be3f3e55e5d440401caeef74066d17b7e (diff)
downloadbrew-95305e6256c73f1e19d7a71c6906a80c69e7c5c8.tar.bz2
New command: `brew unlinkapps`
The name is pretty self explanatory, it unlinks all installed applications found under `brew --prefix` from either `~/Applications` or `/Applications` Closes Homebrew/homebrew#22729. Signed-off-by: Adam Vandenberg <flangy@gmail.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/unlinkapps.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/unlinkapps.rb b/Library/Homebrew/cmd/unlinkapps.rb
new file mode 100644
index 000000000..2f6a57e6e
--- /dev/null
+++ b/Library/Homebrew/cmd/unlinkapps.rb
@@ -0,0 +1,28 @@
+# Unlinks any Applications (.app) found in installed prefixes from /Applications
+require 'keg'
+
+module Homebrew extend self
+
+ def unlinkapps
+ target_dir = ARGV.include?("--local") ? File.expand_path("~/Applications") : "/Applications"
+
+ unless File.exist? target_dir
+ opoo "#{target_dir} does not exist, stopping."
+ puts "Run `mkdir #{target_dir}` first."
+ exit 1
+ end
+
+ cellar_apps = Dir[target_dir + '/*.app'].select do |app|
+ if File.symlink?(app) && File.readlink(app).match(HOMEBREW_CELLAR)
+ File.readlink app
+ end
+ end
+
+ cellar_apps.each do |app|
+ puts "Unlinking #{app}"
+ system "unlink", app
+ end
+
+ puts "Finished unlinking from #{target_dir}" if cellar_apps
+ end
+end