fix(uninstall): respect ZDOTDIR and ZSH environment variables

This commit is contained in:
Codebuff Contributor 2026-05-16 07:05:50 +06:00
commit 1b8bb3615f

View file

@ -16,22 +16,27 @@ if [ "$confirmation" != y ] && [ "$confirmation" != Y ]; then
exit exit
fi fi
echo "Removing ~/.oh-my-zsh" # Use $ZSH if set, otherwise fall back to ~/.oh-my-zsh
if [ -d ~/.oh-my-zsh ]; then : ${ZSH:=~/.oh-my-zsh}
rm -rf ~/.oh-my-zsh # Use $ZDOTDIR if set, otherwise fall back to $HOME
: ${ZDOTDIR:=$HOME}
echo "Removing $ZSH"
if [ -d "$ZSH" ]; then
rm -rf "$ZSH"
fi fi
if [ -e ~/.zshrc ]; then if [ -e "$ZDOTDIR/.zshrc" ]; then
ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S) ZSHRC_SAVE="$ZDOTDIR/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)"
echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}" echo "Found $ZDOTDIR/.zshrc -- Renaming to ${ZSHRC_SAVE}"
mv ~/.zshrc "${ZSHRC_SAVE}" mv "$ZDOTDIR/.zshrc" "${ZSHRC_SAVE}"
fi fi
echo "Looking for original zsh config..." echo "Looking for original zsh config..."
ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh ZSHRC_ORIG="$ZDOTDIR/.zshrc.pre-oh-my-zsh"
if [ -e "$ZSHRC_ORIG" ]; then if [ -e "$ZSHRC_ORIG" ]; then
echo "Found $ZSHRC_ORIG -- Restoring to ~/.zshrc" echo "Found $ZSHRC_ORIG -- Restoring to $ZDOTDIR/.zshrc"
mv "$ZSHRC_ORIG" ~/.zshrc mv "$ZSHRC_ORIG" "$ZDOTDIR/.zshrc"
echo "Your original zsh config was restored." echo "Your original zsh config was restored."
else else
echo "No original zsh config found" echo "No original zsh config found"