Created
May 4, 2023 01:15
-
-
Save Geczy/a63628a6935b20759007fe0111c3e8cb to your computer and use it in GitHub Desktop.
find a list of apps you installed that were not using brew
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Use brew install --cask --force x y z to reinstall the apps found with brew | |
# Get list of all installed applications on Mac | |
IFS=$'\n' app_list=($(mdfind "kMDItemContentTypeTree == 'com.apple.application' && kMDItemCFBundleIdentifier != 'com.apple.Installer' && kMDItemCFBundleIdentifier != 'com.apple.systempreferences'")) | |
# Get the response of the Brew Cask JSON API | |
brew_cask_api_response=$(curl -s https://formulae.brew.sh/api/cask.json) | |
# Get the output of "brew list" | |
brew_list_output=$(brew list) | |
# Loop through each application and check if it's installed with Brew | |
for app in "${app_list[@]}"; do | |
# Get the application name from its path | |
app_name=$(basename "$app") | |
brew_name=$(basename "$app" | sed 's/\.app//' | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g') | |
# Check if the application is installed with Brew | |
if echo "$brew_cask_api_response" | rg -q "\"$app_name\""; then | |
if echo "$brew_list_output" | rg -q "$brew_name"; then | |
echo "" | |
else | |
echo "$app_name is not installed with Brew." | |
fi | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment