zsh: print a user-facing banner when the bootstrap fires
The bootstrap silently installs tools for ~30s+ on a version bump or first login, which looked like an unexplained hang. Now prints a banner explaining what is happening, that it may take a minute, and that subsequent runs are a no-op. The box is built dynamically so the right edge stays aligned regardless of the version string length. Also clarifies the trigger comment in zshrc.
This commit is contained in:
@@ -32,7 +32,10 @@ install_opencode(){
|
|||||||
curl -fsSL https://opencode.ai/install | bash
|
curl -fsSL https://opencode.ai/install | bash
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bootstrap: download and run once per bootstrap version
|
# Bootstrap: download and run once per bootstrap version. Installs missing CLI
|
||||||
|
# tools and oh-my-zsh/plugins across distros; prints a banner so the user knows
|
||||||
|
# what the activity is. Re-runs only when ZSHRC_BOOTSTRAP_VERSION is bumped or
|
||||||
|
# BOOTSTRAP=true is set.
|
||||||
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 -fsSL --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
|
||||||
|
|||||||
@@ -2,6 +2,40 @@ export ZSH_CONFIG=$HOME/.config/zsh
|
|||||||
export OHMYZSH=$ZSH_CONFIG/oh-my-zsh
|
export OHMYZSH=$ZSH_CONFIG/oh-my-zsh
|
||||||
export OHMYZSH_CUSTOM=$OHMYZSH/custom
|
export OHMYZSH_CUSTOM=$OHMYZSH/custom
|
||||||
|
|
||||||
|
# Bootstrap banner — built dynamically so the box stays aligned regardless
|
||||||
|
# of the version string length or terminal width.
|
||||||
|
_bootstrap_banner() {
|
||||||
|
local inner=61 # inner width (between the vertical bars)
|
||||||
|
local pad line
|
||||||
|
local title="Zsh bootstrap - one-time environment setup (v${ZSHRC_BOOTSTRAP_VERSION})"
|
||||||
|
local rule=$(printf '═%.0s' {1..$inner})
|
||||||
|
local mid=$(printf '─%.0s' {1..$inner})
|
||||||
|
# left-pad the title by 2 spaces so it doesn't hug the left bar
|
||||||
|
title=" $title"
|
||||||
|
pad=$(( inner - ${#title} ))
|
||||||
|
(( pad < 0 )) && pad=0
|
||||||
|
echo ""
|
||||||
|
echo "╔${rule}╗"
|
||||||
|
printf '║%s%*s║\n' "$title" "$pad" ""
|
||||||
|
echo "╠${mid}╣"
|
||||||
|
while IFS= read -r line; do
|
||||||
|
line=" $line"
|
||||||
|
pad=$(( inner - ${#line} ))
|
||||||
|
(( pad < 0 )) && pad=0
|
||||||
|
printf '║%s%*s║\n' "$line" "$pad" ""
|
||||||
|
done <<'EOF'
|
||||||
|
This runs on first login or when the bootstrap version
|
||||||
|
changes. It installs missing CLI tools and clones oh-my-zsh
|
||||||
|
+ plugins across distros. Network calls time out after
|
||||||
|
~30s so an unreachable host skips silently. The first run
|
||||||
|
may take a minute; subsequent runs are a no-op.
|
||||||
|
EOF
|
||||||
|
echo "╚${rule}╝"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
_bootstrap_banner
|
||||||
|
unfunction _bootstrap_banner
|
||||||
|
|
||||||
touch ~/.hushlogin
|
touch ~/.hushlogin
|
||||||
mkdir -p "$HOME/.local/bin"
|
mkdir -p "$HOME/.local/bin"
|
||||||
mkdir -p "$ZSH_CONFIG"
|
mkdir -p "$ZSH_CONFIG"
|
||||||
|
|||||||
Reference in New Issue
Block a user