zsh: add --max-time to curl calls to prevent hanging on slow connections

This commit is contained in:
2026-07-29 10:35:18 -04:00
parent b805357f53
commit 52bca5ce38
+4 -4
View File
@@ -16,7 +16,7 @@ export ZSHRC_BOOTSTRAP="$ZSH_CONFIG/.bootstrapped"
update_zshrc(){
local tmp=/tmp/.zshrc.$$
curl -sSL --connect-timeout 5 "$ZSHRC_URL" -o "$tmp" 2>/dev/null || return
curl -sSL --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 -o "$tmp" "$ZSHRC_BOOTSTRAP_URL" 2>/dev/null
curl -sSL --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"
@@ -52,7 +52,7 @@ if [ ! -f "$TMUXCONF" ]; then
# Download to temp file.
# The '&&' ensures the 'mv' only runs if curl succeeds (exit code 0).
if curl -sSL --connect-timeout 5 -o "$TEMP_TMUXCONF" "$TMUXREMOTE"; then
if curl -sSL --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 "$ZSHRC_URL" -o "$tmp" 2>/dev/null
curl -sSL --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