zsh: consolidate updaters into single update_zshrc function
This commit is contained in:
+37
-4
@@ -18,13 +18,46 @@ use_master_branch(){
|
||||
}
|
||||
|
||||
update_zshrc(){
|
||||
local tmp=/tmp/.zshrc.$$
|
||||
curl -fsSL --connect-timeout 5 --max-time 10 "$ZSHRC_URL" -o "$tmp" 2>/dev/null || return
|
||||
if zsh -n "$tmp" 2>/dev/null && ! cmp -s "$tmp" "$HOME/.zshrc" 2>/dev/null; then
|
||||
local tmp
|
||||
# zshrc
|
||||
tmp=/tmp/.zshrc.$$
|
||||
if curl -fsSL --connect-timeout 3 --max-time 8 "$ZSHRC_URL" -o "$tmp" 2>/dev/null \
|
||||
&& [[ -f "$tmp" ]] && zsh -n "$tmp" 2>/dev/null \
|
||||
&& ! cmp -s "$tmp" "$HOME/.zshrc" 2>/dev/null; then
|
||||
echo "Updating zshrc..."
|
||||
mv "$tmp" "$HOME/.zshrc" && echo "Updated. Reloading..." && exec zsh
|
||||
mv "$tmp" "$HOME/.zshrc" && exec zsh
|
||||
fi
|
||||
rm -f "$tmp"
|
||||
# zsh-init
|
||||
tmp=/tmp/.zsh-init.$$
|
||||
if curl -fsSL --connect-timeout 3 --max-time 8 "$ZSHRC_GIT/zsh-init.sh" -o "$tmp" 2>/dev/null \
|
||||
&& [[ -f "$tmp" ]] && ! cmp -s "$tmp" "$ZSH_CONFIG/zsh-init.sh" 2>/dev/null; then
|
||||
echo "Updating zsh-init..."
|
||||
mv "$tmp" "$ZSH_CONFIG/zsh-init.sh"
|
||||
else
|
||||
rm -f "$tmp"
|
||||
fi
|
||||
# zsh-functions
|
||||
tmp=/tmp/.zsh-functions.$$
|
||||
if curl -fsSL --connect-timeout 3 --max-time 8 "$ZSHRC_GIT/zsh-functions.zsh" -o "$tmp" 2>/dev/null \
|
||||
&& [[ -f "$tmp" ]] && ! cmp -s "$tmp" "$ZSH_CONFIG/zsh-functions.zsh" 2>/dev/null; then
|
||||
echo "Updating zsh-functions..."
|
||||
mv "$tmp" "$ZSH_CONFIG/zsh-functions.zsh"
|
||||
else
|
||||
rm -f "$tmp"
|
||||
fi
|
||||
# starship
|
||||
if command -v starship >/dev/null; then
|
||||
tmp=$(mktemp)
|
||||
if curl -fsSL --connect-timeout 3 --max-time 8 "$ZSHRC_GIT/starship.toml" -o "$tmp" 2>/dev/null \
|
||||
&& [[ -f "$tmp" ]] && ! cmp -s "$tmp" "$HOME/.config/starship.toml" 2>/dev/null; then
|
||||
mkdir -p "$HOME/.config"
|
||||
echo "Updating starship..."
|
||||
mv "$tmp" "$HOME/.config/starship.toml"
|
||||
else
|
||||
rm -f "$tmp"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
fix_btopbg(){
|
||||
|
||||
Reference in New Issue
Block a user