1
0
Fork 0

zsh: adopt deja predictive autosuggestions; make deja install version-aware

- .zshrc: replace the zsh-autosuggestions plugin with deja (deja supersedes
  it), and move the auto-dedup PATH block to the top so ~/.local/bin is on
  PATH before plugins/modules load.
- bootstrap scripts (arch/debian + gentoo): clone the deja OMZ plugin and
  install the deja binary via the official checksum-verified installer. The
  binary install now compares the installed version to the latest release
  tag and re-runs the installer when they differ, so re-running the script
  UPGRADES deja (0.4.1 -> 0.4.2) rather than skipping an existing install.
This commit is contained in:
Rain 2026-09-07 03:29:50 -04:00
parent c83451b1d4
commit 7a263fa5f1
3 changed files with 98 additions and 15 deletions

View file

@ -6,7 +6,8 @@
# starship, lazygit, yt-dlp, etc.)
#
# Also: install oh-my-zsh, zsh-autosuggestions, zsh-syntax-highlighting,
# zsh-history-substring-search, fzf-tab.
# zsh-history-substring-search, fzf-tab, and the deja autosuggestion engine
# (binary via official installer + plugin clone).
#
# Runs as the unprivileged user, but uses sudo for system packages.
#
@ -277,6 +278,49 @@ install_zsh_plugin zsh-users/zsh-syntax-highlighting "$ZSH_CUSTOM/plugins/zsh
install_zsh_plugin zsh-users/zsh-history-substring-search "$ZSH_CUSTOM/plugins/zsh-history-substring-search"
install_zsh_plugin Aloxaf/fzf-tab "$ZSH_CUSTOM/plugins/fzf-tab"
install_zsh_plugin Giammarco-Ferranti/deja "$ZSH_CUSTOM/plugins/deja"
# --------------------------- deja (predictive autosuggestions) -------------
# Binary via the official installer (checksum-verified release tarball into
# ~/.local/bin). SHELL is neutralized so the installer never appends its
# activation block to .zshrc — the OMZ plugin cloned above handles that.
# The installer always fetches the LATEST release, so this block also
# UPGRADES an existing install (0.4.1 -> 0.4.2), not just bootstraps a fresh
# one: we compare the installed version to the latest release tag and re-run
# the installer when they differ. `deja import` seeds the suggestion DB from
# $HISTFILE (falls back to ~/.zsh_history); safe to re-run, it dedupes.
DEJA_BIN="$USER_HOME/.local/bin/deja"
deja_install_or_upgrade() {
log "installing/upgrading deja binary via official installer"
if curl -fsSL https://raw.githubusercontent.com/Giammarco-Ferranti/deja/main/install.sh \
| INSTALL_DIR="$USER_HOME/.local/bin" SHELL=/bin/sh sh; then
log "deja now: $("$DEJA_BIN" --version 2>/dev/null | head -1)"
else
log "WARNING: deja install failed; zsh-autosuggestions behavior will be absent. Retry manually."
fi
}
if command -v deja >/dev/null 2>&1; then
INSTALLED_VER="$(deja --version 2>/dev/null | awk '{print $2}')"
LATEST_TAG="$(curl -fsSL https://api.github.com/repos/Giammarco-Ferranti/deja/releases/latest 2>/dev/null \
| grep '"tag_name":' | head -n1 | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')"
LATEST_VER="${LATEST_TAG#v}"
if [[ -z "$LATEST_VER" ]]; then
log "deja present ($INSTALLED_VER); could not check latest, leaving as-is"
elif [[ "$INSTALLED_VER" == "$LATEST_VER" ]]; then
log "deja already at latest ($INSTALLED_VER)"
else
log "deja $INSTALLED_VER != latest $LATEST_TAG — upgrading"
deja_install_or_upgrade
fi
else
log "deja not installed; installing"
deja_install_or_upgrade
fi
if command -v deja >/dev/null 2>&1 && [[ ! -s "$USER_HOME/.local/share/deja/deja.db" ]]; then
log "seeding deja DB from shell history"
HISTFILE="${HISTFILE:-$USER_HOME/.zsh_history}" deja import \
|| log "WARNING: deja import failed; run 'deja import' in an interactive shell later."
fi
# --------------------------- TPM (tmux plugin manager) ---------------------
if [[ ! -d "$USER_HOME/.tmux/plugins/tpm" ]]; then
log "cloning tmux plugin manager"