70 lines
2.3 KiB
Bash
70 lines
2.3 KiB
Bash
use_dev_branch(){
|
|
mkdir -p "$ZSH_CONFIG"
|
|
echo "dev" > "$ZSH_CONFIG/branch"
|
|
export ZSHRC_BRANCH=dev
|
|
export ZSHRC_GIT="https://git.jeremymcclure.com/jeremy/scripts/raw/branch/dev/zsh/"
|
|
export ZSHRC_URL="$ZSHRC_GIT/zshrc"
|
|
export ZSHRC_BOOTSTRAP_URL="$ZSHRC_GIT/zshrc-bootstrap.zsh"
|
|
echo "Switched to dev branch. Run 'update_zshrc' to pull latest."
|
|
}
|
|
|
|
use_master_branch(){
|
|
rm -f "$ZSH_CONFIG/branch"
|
|
export ZSHRC_BRANCH=master
|
|
export ZSHRC_GIT="https://git.jeremymcclure.com/jeremy/scripts/raw/branch/master/zsh/"
|
|
export ZSHRC_URL="$ZSHRC_GIT/zshrc"
|
|
export ZSHRC_BOOTSTRAP_URL="$ZSHRC_GIT/zshrc-bootstrap.zsh"
|
|
echo "Switched to master branch. Run 'update_zshrc' to pull latest."
|
|
}
|
|
|
|
update_zshrc(){
|
|
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" && 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(){
|
|
sed -i 's/theme_background = true/theme_background = false/' ~/.config/btop/btop.conf
|
|
}
|
|
|
|
install_opencode(){
|
|
curl -fsSL https://opencode.ai/install | bash
|
|
}
|