1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-04-05 20:47:08 +08:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Rongxin Liu
6e28bf5178
Merge 32275bd605 into 8df5c1b18b 2026-03-10 10:37:43 +00:00
Alessandro Elio Cantini
8df5c1b18b
fix(last-working-dir): use explicit return 0 in early-exit guards (#13623) 2026-03-10 10:52:12 +01:00
AWS小弟
32275bd605 fix: preserve user .zshrc when no backup exists during uninstall
- When uninstalling, if no original backup (.zshrc.pre-oh-my-zsh) exists,
  restore the current .zshrc with Oh My Zsh lines removed
- Prevents data loss for users who installed years ago on different machines
- Keeps the timestamped backup file for safety

Fixes #13156
Fixes #13328
2026-03-06 12:37:00 +00:00
2 changed files with 8 additions and 2 deletions

View File

@ -23,8 +23,8 @@ lwd() {
#
# - This isn't the first time the plugin is loaded
# - We're not in the $HOME directory (e.g. if terminal opened a different folder)
[[ -z "$ZSH_LAST_WORKING_DIRECTORY" ]] || return
[[ "$PWD" == "$HOME" ]] || return
[[ -z "$ZSH_LAST_WORKING_DIRECTORY" ]] || return 0
[[ "$PWD" == "$HOME" ]] || return 0
if lwd 2>/dev/null; then
ZSH_LAST_WORKING_DIRECTORY=1

View File

@ -35,6 +35,12 @@ if [ -e "$ZSHRC_ORIG" ]; then
echo "Your original zsh config was restored."
else
echo "No original zsh config found"
if [ -e "${ZSHRC_SAVE}" ]; then
echo "Restoring your current config and removing Oh My Zsh lines..."
grep -v 'source.*oh-my-zsh\.sh' "${ZSHRC_SAVE}" > ~/.zshrc
echo "Your config was restored with Oh My Zsh lines removed."
echo "Original file saved at: ${ZSHRC_SAVE}"
fi
fi
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."