Unfortunately `brew linkapps` cannot behave nicely with e.g. Spotlight
using either aliases or symlinks and Homebrew formulae do not build
"proper" `.app` bundles that can be relocated. Instead, please consider
using `brew cask` and migrate formulae using `.app`s to casks.
Remove broken symlinks from `/Applications` and `~/Applications` that
were previously created by `brew linkapps`, but are no longer valid
because formulae were uninstalled or the provided apps have changed.
Add `--dry-run` option as is customary for destructive commands. Update
`bash` completion and man page accordingly. Also correct and update
documentation for both `brew linkapps` and `brew unlinkapps` in more
general terms.
Simplify code by using `Pathname` methods as much as possible. Also
avoid calling external commands for basic functionality like unlinking,
reduce code duplication by using a method from `cmd/linkapps.rb`, count
unlinked symlinks with `ObserverPathnameExtension`, and adjust output
for consistency with `brew linkapps`.
Use `start_with?` to make sure the symlink actually points into one of
the Homebrew directories (depending on given arguments). Previously,
only a substring match was used, which would also remove a symlink to a
hypothetical `/opt/unrelated/usr/local/opt/Unrelated.app`. Even if
unlikely to occur, altering stuff unrelated to Homebrew is bad.
Furthermore, make sure to always use a trailing slash with directories.
Otherwise, e.g., `brew unlinkapps qt` will unlink .app bundles of both
`qt` and `qt5` if both are installed and `brew linkapps qt qt5` was
issued before. (Please ignore that `qt` and `qt5` offer a conflicting
set of .app bundles. This will have to be addressed elsewhere.)
ClosesHomebrew/homebrew#45174.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
The name is pretty self explanatory, it unlinks all installed
applications found under `brew --prefix` from either `~/Applications` or
`/Applications`
ClosesHomebrew/homebrew#22729.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>