fix(zsh): preserve existing zshrc source lines
Remove the automatic migration that deleted legacy source ~/.zsh_user entries during updates.
This commit is contained in:
parent
b93d9ab879
commit
45a2cc0462
29
update.sh
29
update.sh
@ -37,34 +37,6 @@ update_authorized_keys() {
|
|||||||
done <<< "$public_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
|
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/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/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
|
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
|
update_authorized_keys
|
||||||
|
|
||||||
# sudo_id=$(sudo id -u 2>/dev/null)
|
# sudo_id=$(sudo id -u 2>/dev/null)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user