zsh: add --fail to curl calls, fix tmux config re-download every startup

- Add -f/--fail to all curl calls so HTTP error pages (502/404) are not
  written to temp files and mistaken for valid config/scripts
- Fix tmux check at line 49: was testing the directory path with -f
  (always true when dir exists) causing tmux.conf to re-download on
  every shell start; now checks for the actual conf files in both
  tmux and byobu config dirs
This commit is contained in:
2026-07-29 10:52:52 -04:00
parent 52bca5ce38
commit e01bb35043
+7 -7
View File
@@ -16,7 +16,7 @@ export ZSHRC_BOOTSTRAP="$ZSH_CONFIG/.bootstrapped"
update_zshrc(){ update_zshrc(){
local tmp=/tmp/.zshrc.$$ local tmp=/tmp/.zshrc.$$
curl -sSL --connect-timeout 5 --max-time 10 "$ZSHRC_URL" -o "$tmp" 2>/dev/null || return 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 if zsh -n "$tmp" 2>/dev/null && ! cmp -s "$tmp" "$HOME/.zshrc" 2>/dev/null; then
echo "Updating zshrc..." echo "Updating zshrc..."
mv "$tmp" "$HOME/.zshrc" && echo "Updated. Reloading..." && exec zsh mv "$tmp" "$HOME/.zshrc" && echo "Updated. Reloading..." && exec zsh
@@ -35,7 +35,7 @@ install_opencode(){
# Bootstrap: download and run once per bootstrap version # Bootstrap: download and run once per bootstrap version
if [[ ! -f "$ZSHRC_BOOTSTRAP" || "$(cat "$ZSHRC_BOOTSTRAP" 2>/dev/null)" != "$ZSHRC_BOOTSTRAP_VERSION" || "$BOOTSTRAP" == "true" ]]; then if [[ ! -f "$ZSHRC_BOOTSTRAP" || "$(cat "$ZSHRC_BOOTSTRAP" 2>/dev/null)" != "$ZSHRC_BOOTSTRAP_VERSION" || "$BOOTSTRAP" == "true" ]]; then
tmp=/tmp/.zshrc_bootstrap.$$ tmp=/tmp/.zshrc_bootstrap.$$
curl -sSL --connect-timeout 5 --max-time 10 -o "$tmp" "$ZSHRC_BOOTSTRAP_URL" 2>/dev/null curl -fsSL --connect-timeout 5 --max-time 10 -o "$tmp" "$ZSHRC_BOOTSTRAP_URL" 2>/dev/null
if [[ -f "$tmp" ]]; then if [[ -f "$tmp" ]]; then
zsh "$tmp" 2>/dev/null zsh "$tmp" 2>/dev/null
echo "$ZSHRC_BOOTSTRAP_VERSION" > "$ZSHRC_BOOTSTRAP" echo "$ZSHRC_BOOTSTRAP_VERSION" > "$ZSHRC_BOOTSTRAP"
@@ -46,13 +46,13 @@ fi
TMUXCONF="$HOME/.config/tmux" TMUXCONF="$HOME/.config/tmux"
BYOBUCONF="$HOME/.config/byobu" BYOBUCONF="$HOME/.config/byobu"
TMUXREMOTE="$ZSHRC_GIT/tmux.conf" TMUXREMOTE="$ZSHRC_GIT/tmux.conf"
if [ ! -f "$TMUXCONF" ]; then if [ ! -f "$TMUXCONF/tmux.conf" ] && [ ! -f "$BYOBUCONF/.tmux.conf" ]; then
# Create a secure temporary file # Create a secure temporary file
TEMP_TMUXCONF=$(mktemp) TEMP_TMUXCONF=$(mktemp)
# Download to temp file. # Download to temp file.
# The '&&' ensures the 'mv' only runs if curl succeeds (exit code 0). # The '&&' ensures the 'mv' only runs if curl succeeds (exit code 0).
if curl -sSL --connect-timeout 5 --max-time 10 -o "$TEMP_TMUXCONF" "$TMUXREMOTE"; then if curl -fsSL --connect-timeout 5 --max-time 10 -o "$TEMP_TMUXCONF" "$TMUXREMOTE"; then
mkdir -p "$TMUXCONF" "$BYOBUCONF" mkdir -p "$TMUXCONF" "$BYOBUCONF"
cp "$TEMP_TMUXCONF" "$TMUXCONF/tmux.conf" cp "$TEMP_TMUXCONF" "$TMUXCONF/tmux.conf"
mv "$TEMP_TMUXCONF" "$BYOBUCONF/.tmux.conf" mv "$TEMP_TMUXCONF" "$BYOBUCONF/.tmux.conf"
@@ -130,7 +130,7 @@ alias yeet='yay -Rcs'
# Auto-update: check every shell start, silently fail if server unreachable # Auto-update: check every shell start, silently fail if server unreachable
if [[ -o interactive ]]; then if [[ -o interactive ]]; then
tmp=/tmp/.zshrc.$$ tmp=/tmp/.zshrc.$$
curl -sSL --connect-timeout 3 --max-time 8 "$ZSHRC_URL" -o "$tmp" 2>/dev/null curl -fsSL --connect-timeout 3 --max-time 8 "$ZSHRC_URL" -o "$tmp" 2>/dev/null
if [[ -f "$tmp" ]] && zsh -n "$tmp" 2>/dev/null && ! cmp -s "$tmp" "$HOME/.zshrc" 2>/dev/null; then if [[ -f "$tmp" ]] && zsh -n "$tmp" 2>/dev/null && ! cmp -s "$tmp" "$HOME/.zshrc" 2>/dev/null; then
echo "Updating zshrc..." echo "Updating zshrc..."
mv "$tmp" "$HOME/.zshrc" && exec zsh mv "$tmp" "$HOME/.zshrc" && exec zsh