diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb index 5a6f957928..19bbef2e8a 100644 --- a/Library/Homebrew/cmd/cleanup.rb +++ b/Library/Homebrew/cmd/cleanup.rb @@ -22,6 +22,8 @@ module Homebrew description: "Scrub the cache, including downloads for even the latest versions. "\ "Note downloads for any installed formula or cask will still not be deleted. "\ "If you want to delete those too: `rm -rf \"$(brew --cache)\"`" + switch "--prune-prefix", + description: "Only prune the symlinks and directories from the prefix and remove no other files." switch :verbose switch :debug end @@ -31,6 +33,10 @@ module Homebrew cleanup_args.parse cleanup = Cleanup.new(*args.remaining, dry_run: args.dry_run?, scrub: args.s?, days: args.prune&.to_i) + if args.prune_prefix? + cleanup.prune_prefix_symlinks_and_directories + return + end cleanup.clean! diff --git a/Library/Homebrew/cmd/prune.rb b/Library/Homebrew/cmd/prune.rb index 89500eb633..cc9661849d 100644 --- a/Library/Homebrew/cmd/prune.rb +++ b/Library/Homebrew/cmd/prune.rb @@ -23,6 +23,6 @@ module Homebrew def prune prune_args.parse - odisabled("'brew prune'", "'brew cleanup'") + odisabled("'brew prune'", "'brew cleanup --prune-prefix'") end end diff --git a/docs/Manpage.md b/docs/Manpage.md index f41fc7025b..e0b23a4236 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -63,6 +63,8 @@ only do this for the specified formulae and casks. Show what would be removed, but do not actually remove anything. * `-s`: Scrub the cache, including downloads for even the latest versions. Note downloads for any installed formula or cask will still not be deleted. If you want to delete those too: `rm -rf "$(brew --cache)"` +* `--prune-prefix`: + Only prune the symlinks and directories from the prefix and remove no other files. ### `command` *`cmd`* diff --git a/manpages/brew.1 b/manpages/brew.1 index c98b8b6f0f..416e329d81 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -62,6 +62,10 @@ Show what would be removed, but do not actually remove anything\. \fB\-s\fR Scrub the cache, including downloads for even the latest versions\. Note downloads for any installed formula or cask will still not be deleted\. If you want to delete those too: \fBrm \-rf "$(brew \-\-cache)"\fR . +.TP +\fB\-\-prune\-prefix\fR +Only prune the symlinks and directories from the prefix and remove no other files\. +. .SS "\fBcommand\fR \fIcmd\fR" Display the path to the file which is used when invoking \fBbrew\fR \fIcmd\fR\. .