Skip to content

Instantly share code, notes, and snippets.

@brei0x
Last active January 19, 2026 12:44
Show Gist options
  • Select an option

  • Save brei0x/254e58bd87009963b3f58405d75cbe6c to your computer and use it in GitHub Desktop.

Select an option

Save brei0x/254e58bd87009963b3f58405d75cbe6c to your computer and use it in GitHub Desktop.
Uninstall Zsh + Oh My Zsh + Powerlevel10k theme (macOS & Linux)
#!/bin/bash
# Uninstall Zsh + Oh My Zsh + Powerlevel10k theme (macOS & Linux)
# To run this script:
# 1. Execute: sh -c "$(curl -fsSL "$(curl -s "https://api.github.com/gists/254e58bd87009963b3f58405d75cbe6c" | grep -o '"raw_url": *"[^"]*"' | cut -d'"' -f4)")"
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
# Logging functions
log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
log_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
# Function to check if a command exists
command_exists() {
command -v "$1" > /dev/null 2>&1
}
# Check OS compatibility
OS="$(uname -s)"
if [ "$OS" != "Darwin" ] && [ "$OS" != "Linux" ]; then
log_error "This script is designed to run on macOS or Linux. Exiting."
exit 1
fi
# Remove Powerlevel10k config
if [ -f "$HOME/.p10k.zsh" ]; then
log_info "Removing Powerlevel10k configuration..."
rm -f ~/.p10k.zsh
else
log_info "Powerlevel10k configuration not found."
fi
# Remove Powerlevel10k theme
P10K_DIR="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"
if [ -d "$P10K_DIR" ]; then
log_info "Removing Powerlevel10k theme..."
rm -rf "$P10K_DIR"
else
log_info "Powerlevel10k theme not found."
fi
# Run Oh My Zsh uninstaller if present
if [ -f "$HOME/.oh-my-zsh/tools/uninstall.sh" ]; then
log_info "Removing Oh My Zsh..."
sh ~/.oh-my-zsh/tools/uninstall.sh --unattended
else
log_info "Oh My Zsh not found."
fi
# Switch back to bash if needed
CURRENT_SHELL="$(basename "$SHELL")"
if [ "$CURRENT_SHELL" != "bash" ]; then
log_info "Switching default shell to bash..."
if [ "$OS" = "Darwin" ]; then
chsh -s /bin/bash
else
sudo usermod -s /bin/bash "$(whoami)"
fi
else
log_info "Bash is already the default shell."
fi
# Uninstall Zsh if installed
if command_exists zsh; then
log_info "Uninstalling Zsh..."
if [ "$OS" = "Darwin" ]; then
brew uninstall zsh
else
sudo apt remove zsh -y
sudo apt autoremove -y
fi
else
log_info "Zsh is not installed."
fi
# Clean up remaining zsh config files
if ls ~/.zsh* 1> /dev/null 2>&1; then
log_info "Cleaning up remaining Zsh configuration files..."
rm -rf ~/.zsh*
else
log_info "No remaining Zsh configuration files found."
fi
echo ""
log_info "Uninstallation complete!"
log_info "To apply the shell change, run: ${GREEN}exec bash${NC}"
@carl-meyer-dev
Copy link

Thanks this was very useful

@David-cmd11
Copy link

Uffff por fin, un resultado, mil gracias!

@EbodShojaei
Copy link

Thanks this was very useful

ditto

@anvesh3223
Copy link

thank you so much......very very helpful

@suyash20-debug
Copy link

suyash20-debug commented Jun 19, 2024

thanks .. saved so much of my time

@Agslz
Copy link

Agslz commented Jul 6, 2024

Nice script!

@hamolicious
Copy link

Thank you, very useful.

@littlekath25
Copy link

Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment