You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When testing, bootstrapping and reinstalling a machine, I'd like to have the ability to uninstall all apps from a single command.
Describe the solution you'd like
Something similar to the function below, that I've been currently using.
function mas-nuke {
sudo -v
while IFS= read -r LINE; do
APP_ID=$(echo $LINE | awk '{print $1;}');
#sudo mas uninstall $ID; # fails, issue with `mas` package
APP_DRY=$(mas uninstall $APP_ID --dry-run)
APP_DATA=$(echo $APP_DRY | head -n1)
APP_PATH=$(echo '/'${APP_DATA#*/})
#APP_NAME=$(echo $APP_DATA | cut -d "/" -f 1)
echo "Uninstalling" $APP_PATH " ..."
sudo chown $(id -un) $APP_PATH # change ownership to user
trash $APP_PATH
done <<< "$(mas list)" # Feed list into loop
With the change in ownership, I was able to not require sudo and send the app to the user trash, not the root one.
Note: sending to the trash relies on brew install trash.
Describe alternatives you've considered
A similar function could be defined with rm instead of trash.
Also, the current implementation does not "appclean" the mac. It only uninstalls the app, but all associated files stay. A more thorough function could be implemented with mdfind.
Additional context
(none)
The text was updated successfully, but these errors were encountered:
This is possible to achieve with standard unix tools awk and xargs. I suggest implementing this in mas directly would be an anti-pattern at odds with the unix philosophy of "do one thing and do it well".
The requested behavior could be implemented easily with a command like the one below. If mas uninstall doesn't work, that should be fixed rather than adding another uninstall function that reimplements the same functionality.
mas list | awk '{print $1}' | xargs -I '{}' mas uninstall '{}'
If this is too verbose, I'd suggest implementing an API like:
# allow printing only IDs from mas list
mas list -q
# allow uninstalling multiple IDs with the mas uninstall command
mas uninstall <id1> <id2>
# use them together
mas list -q | xargs mas uninstall
Personally I don't think it makes sense to add functionality outside of what is available in the app store. But if cleaning up app data is desired, it should be added to the base uninstall command as an option rather than implementing a 2nd way to delete an app.
Is your feature request related to a problem? Please describe.
When testing, bootstrapping and reinstalling a machine, I'd like to have the ability to uninstall all apps from a single command.
Describe the solution you'd like
Something similar to the function below, that I've been currently using.
With the change in ownership, I was able to not require
sudo
and send the app to the user trash, not the root one.Note: sending to the trash relies on
brew install trash
.Describe alternatives you've considered
A similar function could be defined with
rm
instead oftrash
.Also, the current implementation does not "appclean" the mac. It only uninstalls the app, but all associated files stay. A more thorough function could be implemented with
mdfind
.Additional context
(none)
The text was updated successfully, but these errors were encountered: