From 45a2cc046230efe0fed8a490e7eab67a2a3e73c2 Mon Sep 17 00:00:00 2001 From: Konano Date: Tue, 8 Sep 2026 12:13:17 +0800 Subject: [PATCH] fix(zsh): preserve existing zshrc source lines Remove the automatic migration that deleted legacy source ~/.zsh_user entries during updates. --- update.sh | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/update.sh b/update.sh index c407782..80b0c8b 100755 --- a/update.sh +++ b/update.sh @@ -37,34 +37,6 @@ update_authorized_keys() { done <<< "$public_keys" } -remove_legacy_zsh_user_source() { - local zshrc="$HOME/.zshrc" - local init_file="$HOME/.oh-my-zsh/custom/00-init.zsh" - [ -f "$zshrc" ] || return - grep -q '^add-zsh-hook precmd __zsh_load_user_config$' "$init_file" 2>/dev/null || return - - local temp_file - temp_file=$(mktemp "${zshrc}.XXXXXX") || return 1 - - awk ' - { - line = $0 - sub(/^[[:space:]]+/, "", line) - sub(/[[:space:]]+$/, "", line) - if (line != "source ~/.zsh_user" && line != ". ~/.zsh_user") print - } - ' "$zshrc" > "$temp_file" - - if cmp -s "$zshrc" "$temp_file"; then - rm "$temp_file" - return - fi - - cp "$temp_file" "$zshrc" - rm "$temp_file" - echo "Legacy source ~/.zsh_user line has been removed from $zshrc." -} - # ============================================================ update_file $scriptdir/files/.nanorc ~/.nanorc @@ -79,7 +51,6 @@ update_file $scriptdir/files/zsh/51-alias.zsh ~/.oh-my-zsh/custom/51-a update_file $scriptdir/files/zsh/80-proxy.zsh ~/.oh-my-zsh/custom/80-proxy.zsh update_file $scriptdir/files/zsh/90-other.zsh ~/.oh-my-zsh/custom/90-other.zsh update_file $scriptdir/files/zsh/ys-simple.zsh-theme ~/.oh-my-zsh/custom/themes/ys-simple.zsh-theme -remove_legacy_zsh_user_source update_authorized_keys # sudo_id=$(sudo id -u 2>/dev/null)