Skip to content

Instantly share code, notes, and snippets.

@ChrisColeTech
Last active August 17, 2025 13:31
Show Gist options
  • Select an option

  • Save ChrisColeTech/42d5862c4817c269ef6aa42f7ff490ce to your computer and use it in GitHub Desktop.

Select an option

Save ChrisColeTech/42d5862c4817c269ef6aa42f7ff490ce to your computer and use it in GitHub Desktop.
Windows Toast Notifications - Bash Uninstallation Script for WSL
#!/usr/bin/env bash
# WSL Toast Notification Uninstaller
# This script removes the toast() function from WSL shell configurations
# Usage: bash wsl_toast_uninstall.sh
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Configuration
RC_FILES=(~/.bashrc ~/.zshrc)
SNIPPET_START="# -- wsl toast helper start --"
SNIPPET_END="# -- wsl toast helper end --"
echo "=== WSL Toast Notification Uninstaller ==="
echo
print_status "Removing WSL toast helper from shell configuration files..."
# Remove executable toast script if it exists
TOAST_SCRIPT="$HOME/bin/toast"
if [[ -f "$TOAST_SCRIPT" ]]; then
print_status "Removing executable toast script: $TOAST_SCRIPT"
rm -f "$TOAST_SCRIPT"
print_status "✓ Removed executable toast script"
fi
removed_count=0
# Process each shell configuration file
for rc in "${RC_FILES[@]}"; do
rc_expanded="$(eval echo "${rc}")"
if [[ ! -f "$rc_expanded" ]]; then
print_warning "File not found: $rc_expanded"
continue
fi
# Check if snippet is present
if ! grep -Fq "$SNIPPET_START" "$rc_expanded"; then
print_status "Toast helper not found in $rc_expanded"
continue
fi
print_status "Removing toast helper from $rc_expanded"
# Create a temporary file
temp_file=$(mktemp)
# Process the file line by line
in_snippet=false
while IFS= read -r line; do
if [[ "$line" == "$SNIPPET_START" ]]; then
in_snippet=true
continue
elif [[ "$line" == "$SNIPPET_END" ]]; then
in_snippet=false
continue
elif [[ "$in_snippet" == false ]]; then
echo "$line" >> "$temp_file"
fi
done < "$rc_expanded"
# Replace original file with cleaned version
mv "$temp_file" "$rc_expanded"
removed_count=$((removed_count + 1))
print_status "✓ Removed from $rc_expanded"
done
if [[ $removed_count -eq 0 ]]; then
print_warning "No toast helper installations found to remove"
else
print_status "Removed toast helper from $removed_count file(s)"
fi
echo
print_status "Uninstall complete!"
echo
if [[ $removed_count -gt 0 ]]; then
echo "The toast function has been removed from your shell configuration files."
echo "To apply changes to your current session:"
echo " source ~/.bashrc # if you use bash"
echo " source ~/.zshrc # if you use zsh"
echo
echo "Or open a new terminal window."
echo
# Test if function is still available in current session
if command -v toast >/dev/null 2>&1; then
print_warning "The toast function is still available in your current session"
print_warning "Please restart your terminal or source your shell configuration"
else
print_status "✓ Toast function is no longer available in current session"
fi
fi
echo "Note: This script only removes the WSL toast helper."
echo "To remove Windows toast notifications, run the Windows uninstaller:"
echo " powershell -ExecutionPolicy Bypass -File windows_toast_uninstall.ps1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment