From 0f48444ffd29076c64717265e981667f73df5ea5 Mon Sep 17 00:00:00 2001 From: TrudeEH Date: Fri, 22 Mar 2024 15:24:14 +0000 Subject: [PATCH] App To Brew Script rewrite --- BrewFile | 3 -- darwinSettings.sh | 4 +-- scripts/brewBundle.sh | 0 scripts/moveAppsToBrew.sh | 60 +++++++++++++++++++++++++++++++-------- scripts/symlink-files.sh | 0 5 files changed, 50 insertions(+), 17 deletions(-) mode change 100644 => 100755 scripts/brewBundle.sh mode change 100644 => 100755 scripts/symlink-files.sh diff --git a/BrewFile b/BrewFile index f2bfdd16..9f5fe337 100644 --- a/BrewFile +++ b/BrewFile @@ -16,8 +16,6 @@ brew "wget" cask "anydesk" # Reclaim tens of gigabytes of your storage used for various Xcode caches cask "devcleaner" -# Utilities designed to make common development tasks easier -cask "devtoys" # Matrix collaboration client cask "element" # Web browser @@ -93,5 +91,4 @@ vscode "streetsidesoftware.code-spell-checker-portuguese" vscode "vadimcn.vscode-lldb" vscode "visualstudioexptteam.intellicode-api-usage-examples" vscode "visualstudioexptteam.vscodeintellicode" -vscode "vscodevim.vim" vscode "wix.vscode-import-cost" diff --git a/darwinSettings.sh b/darwinSettings.sh index fd725547..07e4b3a7 100755 --- a/darwinSettings.sh +++ b/darwinSettings.sh @@ -136,8 +136,8 @@ defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 # defaults -currentHost write NSGlobalDomain com.apple.trackpad.trackpadCornerClickBehavior -int 1 # defaults -currentHost write NSGlobalDomain com.apple.trackpad.enableSecondaryClick -bool true -# Disable “natural” (Lion-style) scrolling -defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false +# Enable “natural” (Lion-style) scrolling +defaults write NSGlobalDomain com.apple.swipescrolldirection -bool true # Increase sound quality for Bluetooth headphones/headsets defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40 diff --git a/scripts/brewBundle.sh b/scripts/brewBundle.sh old mode 100644 new mode 100755 diff --git a/scripts/moveAppsToBrew.sh b/scripts/moveAppsToBrew.sh index af5408aa..024453b0 100755 --- a/scripts/moveAppsToBrew.sh +++ b/scripts/moveAppsToBrew.sh @@ -1,22 +1,58 @@ -#!/bin/bash +#!/bin/zsh + +RED="\e[31m" +GREEN="\e[32m" +GRAY="\e[90m" +BOLD="\e[1m" +ENDCOLOR="\e[0m" # List all installed apps all_apps=(/Applications/*) +homebrew_apps=$(brew list --casks) +not_found_list=() +brew_available=() -# Loop through each app for app in "${all_apps[@]}"; do - # Extract the app name without the extension (if any) - app_name="${app##*/}" - app_name="${app_name%.*}" # Removes everything after the last dot + # Extract the name of the app without the path + app_name=$(basename "$app") + app_name="${app_name%.*}" + app_name=$(echo "$app_name" | tr '[:upper:]' '[:lower:]') + app_name=$(echo "$app_name" | tr " " -) - # Check if the app name exists in a brew cask - brew search $app_name &> /dev/null - if [ $? -eq 0 ]; then - echo "Found $app_name in Homebrew. Installing..." - brew install --cask --force "$app_name" + if [[ $app_name == "utilities" ]]; then continue; fi + + echo -ne "${GRAY}Checking app: ${ENDCOLOR}${BOLD}$app_name${ENDCOLOR}${GRAY}...${ENDCOLOR}" + # Check if app is in homebrew list, if not print its name to terminal + echo $homebrew_apps | grep -wq $app_name + if [[ $? == 0 ]]; then + echo -e " ${GREEN}TRUE${ENDCOLOR}" else - echo "$app_name not found in Homebrew." + echo -e " ${RED}FALSE${ENDCOLOR}" + not_found_list+=($app_name) + + # Check if app is available with brew + brew search --cask -q $app_name &>/dev/null | grep -x $app_name &>/dev/null + if [ $? -eq 0 ]; then + brew_available+=($app_name) + fi fi done -echo "All checks completed." +echo +echo "-------------------------------------" +echo +echo -e "${BOLD}Not installed with brew: ${ENDCOLOR}$not_found_list" +echo +echo -e "${BOLD}Available in brew: ${ENDCOLOR}$brew_available" +echo +if [[ ! -z $brew_available ]]; then + echo "-------------------------------------" + echo + echo -n "Replace the existing (available) apps with brew casks? (y/n): " + read replaceApps + if [[ $replaceApps == "y" ]]; then + for app in "${brew_available[@]}"; do + brew install --cask --force $app + done + fi +fi diff --git a/scripts/symlink-files.sh b/scripts/symlink-files.sh old mode 100644 new mode 100755