Skip to content

Instantly share code, notes, and snippets.

@naranyala
Created June 20, 2026 09:25
Show Gist options
  • Select an option

  • Save naranyala/b34ba5a1c2afab643b870b371f86e412 to your computer and use it in GitHub Desktop.

Select an option

Save naranyala/b34ba5a1c2afab643b870b371f86e412 to your computer and use it in GitHub Desktop.
select-and-uninstall-snap-pkg.sh
#!/usr/bin/env bash
set -e
########################################
# Snap Uninstaller Selector
########################################
# Ensure snap is installed
if ! command -v snap >/dev/null 2>&1; then
echo "❌ Snap is not installed. Please install it first."
exit 1
fi
# Get list of installed Snap package names
mapfile -t apps < <(snap list | awk 'NR>1 {print $1}')
if [[ ${#apps[@]} -eq 0 ]]; then
echo "⚠️ No Snap packages installed."
exit 0
fi
echo "πŸ”Ž Installed Snap packages:"
PS3="Enter the number of the Snap you want to uninstall: "
select app_id in "${apps[@]}"; do
if [[ -n "$app_id" ]]; then
echo "❗ You selected: $app_id"
read -rp "Are you sure you want to uninstall $app_id? [y/N]: " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
sudo snap remove "$app_id"
echo "βœ… $app_id has been uninstalled."
else
echo "🚫 Uninstall cancelled."
fi
break
else
echo "Invalid choice. Try again."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment