Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command to uninstall all apps from App Store #511

Open
tplobo opened this issue Feb 23, 2024 · 0 comments
Open

Command to uninstall all apps from App Store #511

tplobo opened this issue Feb 23, 2024 · 0 comments

Comments

@tplobo
Copy link

tplobo commented Feb 23, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant