Skip to content

Instantly share code, notes, and snippets.

@kernjackson
Created December 19, 2024 16:20
Show Gist options
  • Select an option

  • Save kernjackson/9226259e755a30ee145522504430baf5 to your computer and use it in GitHub Desktop.

Select an option

Save kernjackson/9226259e755a30ee145522504430baf5 to your computer and use it in GitHub Desktop.
Completely Uninstalls Google Chrome from macOS
#!/bin/bash
echo "Starting the removal of Google Chrome and its associated files..."
# Function to delete a folder or file with confirmation
delete_item() {
if [ -e "$1" ]; then
read -p "Are you sure you want to delete: $1? (y/n) " confirm
if [[ $confirm == [yY] ]]; then
echo "Deleting: $1"
rm -rf "$1"
else
echo "Skipping: $1"
fi
else
echo "Not found: $1"
fi
}
# Quit Google Chrome if running
echo "Closing Google Chrome and related processes..."
read -p "Do you want to close Google Chrome? (y/n) " close_chrome
if [[ $close_chrome == [yY] ]]; then
pkill "Google Chrome" 2>/dev/null || echo "Google Chrome is not running."
fi
read -p "Do you want to close Google Software Update? (y/n) " close_update
if [[ $close_update == [yY] ]]; then
pkill "GoogleSoftwareUpdate" 2>/dev/null || echo "Google Software Update is not running."
fi
# Remove the Chrome application
echo "Removing Google Chrome from Applications..."
delete_item "/Applications/Google Chrome.app"
# Remove Chrome-related files in the user's Library
echo "Removing Chrome user data and cache files..."
delete_item "$HOME/Library/Application Support/Google/Chrome"
delete_item "$HOME/Library/Caches/Google/Chrome"
delete_item "$HOME/Library/Caches/com.google.Chrome"
delete_item "$HOME/Library/Saved Application State/com.google.Chrome.savedState"
delete_item "$HOME/Library/Preferences/com.google.Chrome.plist"
# Remove Google Software Update files
echo "Removing Google Software Update files..."
delete_item "/Library/Google/GoogleSoftwareUpdate"
delete_item "/Library/LaunchAgents/com.google.keystone.agent.plist"
delete_item "/Library/LaunchDaemons/com.google.keystone.daemon.plist"
# Attempt to remove Keystone using ~ if it exists
KSINSTALL_PATH="$HOME/Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/Contents/Resources/ksinstall"
if [ -f "$KSINSTALL_PATH" ]; then
echo "Removing Keystone using ksinstall..."
"$KSINSTALL_PATH" --nuke
else
echo "Keystone ksinstall not found."
fi
# Empty the Trash
# echo "Emptying Trash..."
# read -p "Are you sure you want to empty the Trash? (y/n) " empty_trash
# if [[ $empty_trash == [yY] ]]; then
# rm -rf ~/.Trash/*
# fi
# Restart suggestion
echo "It is recommended to restart your Mac to ensure all processes are terminated."
echo "Google Chrome and associated files have been removed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment