From e01bb35043b2e564f3229e811683058fdb3900c7 Mon Sep 17 00:00:00 2001 From: Jeremy McClure Date: Wed, 29 Jul 2026 10:52:52 -0400 Subject: [PATCH] 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 --- zsh/zshrc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/zsh/zshrc b/zsh/zshrc index a9f2a3e..b80b1cb 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -16,7 +16,7 @@ export ZSHRC_BOOTSTRAP="$ZSH_CONFIG/.bootstrapped" update_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 echo "Updating zshrc..." mv "$tmp" "$HOME/.zshrc" && echo "Updated. Reloading..." && exec zsh @@ -35,7 +35,7 @@ install_opencode(){ # Bootstrap: download and run once per bootstrap version if [[ ! -f "$ZSHRC_BOOTSTRAP" || "$(cat "$ZSHRC_BOOTSTRAP" 2>/dev/null)" != "$ZSHRC_BOOTSTRAP_VERSION" || "$BOOTSTRAP" == "true" ]]; then 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 zsh "$tmp" 2>/dev/null echo "$ZSHRC_BOOTSTRAP_VERSION" > "$ZSHRC_BOOTSTRAP" @@ -46,13 +46,13 @@ fi TMUXCONF="$HOME/.config/tmux" BYOBUCONF="$HOME/.config/byobu" TMUXREMOTE="$ZSHRC_GIT/tmux.conf" -if [ ! -f "$TMUXCONF" ]; then +if [ ! -f "$TMUXCONF/tmux.conf" ] && [ ! -f "$BYOBUCONF/.tmux.conf" ]; then # Create a secure temporary file TEMP_TMUXCONF=$(mktemp) - - # Download to temp file. + + # Download to temp file. # 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" cp "$TEMP_TMUXCONF" "$TMUXCONF/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 if [[ -o interactive ]]; then 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 echo "Updating zshrc..." mv "$tmp" "$HOME/.zshrc" && exec zsh