zsh: add zoxide/bat/delta, starship prompt config, extra history options; rewrite README

Bootstrap (zshrc-bootstrap.zsh):
- Add bat and zoxide to the cross-distro install loop
- Add git-delta install block (package is 'git-delta' on every PM but
  binary is 'delta', mirroring the starship/lazydocker pattern)
- Debian/Ubuntu compat: symlink batcat->bat and fdfind->fd into
  ~/.local/bin so zshrc integrations work under both names
- Bump ZSHRC_BOOTSTRAP_VERSION 2 -> 3 so existing machines re-run the
  bootstrap and auto-install the new tools

zshrc:
- Add setopts HIST_VERIFY, EXTENDED_HISTORY, AUTO_PUSHD,
  PUSHD_IGNORE_DUPS, PUSHD_SILENT
- Self-configuring tool integrations (all behind command -v guards):
  - zoxide: eval $(zoxide init zsh) for frecent 'z'/'zi' dir jumping
  - bat: alias cat->bat, BAT_THEME, colored MANPAGER via bat
  - delta: GIT_PAGER=delta for prettier git diff/log/show
- Extend the interactive auto-update block to also sync starship.toml
  to ~/.config/starship.toml (overwrite-if-changed, validated the
  same way as zshrc); keep the reproducible/self-configuring design
- Inverted hyperlink fix already landed in prior commit; no change
  here

starship.toml (new):
- Two-line prompt: directory + git status + cmd duration on line 1,
  arrow (red on error) on line 2; Nerd Font symbols, SSH host/user,
  Python/Node/Rust/Go/Java/Docker context blocks
- Validated clean with starship 1.21.1 (uses [nodejs], not [node])

README.md:
- Full rewrite: documents the design philosophy, all files, deps,
  integrations, history options, aliases, keybindings, the eza
  hyperlink workaround rationale, auto-update behavior, per-machine
  overrides, env vars, and helper functions
This commit is contained in:
2026-07-29 11:30:49 -04:00
parent c4a804e760
commit 10caebad29
4 changed files with 294 additions and 11 deletions
+45 -4
View File
@@ -6,7 +6,7 @@ export ZSHRC_GIT="https://git.jeremymcclure.com/jeremy/scripts/raw/branch/master
export ZSHRC_URL="$ZSHRC_GIT/zshrc"
export ZSHRC_BOOTSTRAP_URL="$ZSHRC_GIT/zshrc-bootstrap.zsh"
export ZSHRC_BOOTSTRAP_VERSION="2"
export ZSHRC_BOOTSTRAP_VERSION="3"
export ZSHRC_BOOTSTRAP="$ZSH_CONFIG/.bootstrapped"
[[ -d "$HOME/Scripts" ]] && path+=("$HOME/Scripts")
@@ -76,6 +76,11 @@ setopt HIST_FCNTL_LOCK
setopt AUTO_CD
setopt AUTO_LIST
setopt INTERACTIVE_COMMENTS
setopt HIST_VERIFY
setopt EXTENDED_HISTORY
setopt AUTO_PUSHD
setopt PUSHD_IGNORE_DUPS
setopt PUSHD_SILENT
ZSH_THEME=""
ENABLE_CORRECTION="false"
@@ -132,21 +137,57 @@ for _ea in la ldot lD lDD ll ls lsd lsdl lS lT; do
done
unset _ea
# --- Tool integrations (self-configuring: enabled only when the tool exists) ---
# zoxide: frecency-based directory jumping — `z <substring>` / `zi` (fzf picker).
# Replaces nothing; `cd` still works. Auto-installed by the bootstrap.
command -v zoxide >/dev/null && eval "$(zoxide init zsh)" 2>/dev/null
# bat: colored `cat` and colored man pages. bat/batcat handled by bootstrap.
if command -v bat >/dev/null; then
alias cat='bat'
export BAT_THEME="${BAT_THEME:-Monokai Extended}"
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
export MANROFFOPT='-c'
fi
# delta: prettier git diffs as git's pager (git respects GIT_PAGER). Auto-installed
# by the bootstrap. Not aliased to `diff` since delta reads diff input on stdin,
# not two file arguments — GIT_PAGER is the correct integration.
command -v delta >/dev/null && export GIT_PAGER='delta'
alias c='clear'
alias q="exit"
alias nbstat=$'netbird status --json | jq -r \'.peers.details[]? | [(.hostname // .fqdn), .netbirdIp, .status] | @tsv\' | column -t -s $\'\\t\''
alias open-ports="ss -tulpn | grep LISTEN"
alias yeet='yay -Rcs'
# Auto-update: check every shell start, silently fail if server unreachable
# Auto-update self and managed configs: checked every interactive shell start,
# silently skipped if the server is unreachable. Keeps zshrc + starship.toml in
# sync across machines (reproducible/self-configuring); only reloads the shell
# when the zshrc itself changes (starship applies its config live per render).
if [[ -o interactive ]]; then
# zshrc (reload shell if changed)
tmp=/tmp/.zshrc.$$
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 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"
# starship prompt config (overwrite if changed; applied live on next render)
if command -v starship >/dev/null; then
stmp=$(mktemp)
if curl -fsSL --connect-timeout 3 --max-time 8 "$ZSHRC_GIT/starship.toml" -o "$stmp" 2>/dev/null \
&& [[ -f "$stmp" ]] && ! cmp -s "$stmp" "$HOME/.config/starship.toml" 2>/dev/null; then
mkdir -p "$HOME/.config"
mv "$stmp" "$HOME/.config/starship.toml"
else
rm -f "$stmp"
fi
fi
fi
[[ -f $HOME/.zshrc.local ]] || touch $HOME/.zshrc.local