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>
This commit is contained in:
parent
076df32be3
commit
95305e6256
28
Library/Homebrew/cmd/unlinkapps.rb
Normal file
28
Library/Homebrew/cmd/unlinkapps.rb
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user