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:
parent
c83451b1d4
commit
7a263fa5f1
3 changed files with 98 additions and 15 deletions
|
|
@ -239,12 +239,13 @@ else
|
|||
log "oh-my-zsh already installed"
|
||||
fi
|
||||
|
||||
# Plugins: zsh-autosuggestions, zsh-syntax-highlighting, zsh-history-substring-search, fzf-tab
|
||||
# Plugins: zsh-autosuggestions, zsh-syntax-highlighting, zsh-history-substring-search, fzf-tab, deja
|
||||
declare -A PLUGINS=(
|
||||
[zsh-autosuggestions]="https://github.com/zsh-users/zsh-autosuggestions"
|
||||
[zsh-syntax-highlighting]="https://github.com/zsh-users/zsh-syntax-highlighting"
|
||||
[zsh-history-substring-search]="https://github.com/zsh-users/zsh-history-substring-search"
|
||||
[fzf-tab]="https://github.com/Aloxaf/fzf-tab"
|
||||
[deja]="https://github.com/Giammarco-Ferranti/deja"
|
||||
)
|
||||
for plugin in "${!PLUGINS[@]}"; do
|
||||
if [[ -d "$ZSH_CUSTOM/plugins/$plugin" ]]; then
|
||||
|
|
@ -255,6 +256,43 @@ for plugin in "${!PLUGINS[@]}"; do
|
|||
fi
|
||||
done
|
||||
|
||||
# deja predictive autosuggestions: binary via official installer (into
|
||||
# ~/.local/bin), then seed DB from history. SHELL neutralized so the
|
||||
# installer never touches .zshrc — the plugin above handles activation.
|
||||
# The installer always fetches the LATEST release, so this also UPGRADES an
|
||||
# existing install (0.4.1 -> 0.4.2) when the installed version lags the
|
||||
# latest release tag — not just a first-run bootstrap.
|
||||
DEJA_BIN="$USER_HOME/.local/bin/deja"
|
||||
deja_install_or_upgrade() {
|
||||
log "installing/upgrading deja binary via official installer"
|
||||
curl -fsSL https://raw.githubusercontent.com/Giammarco-Ferranti/deja/main/install.sh \
|
||||
| INSTALL_DIR="$USER_HOME/.local/bin" SHELL=/bin/sh sh \
|
||||
|| log "WARNING: deja install failed; retry manually."
|
||||
log "deja now: $("$DEJA_BIN" --version 2>/dev/null | head -1)"
|
||||
}
|
||||
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' later."
|
||||
fi
|
||||
|
||||
# Step 8: tpm (tmux plugin manager)
|
||||
if [[ ! -d "$USER_HOME/.tmux/plugins/tpm" ]]; then
|
||||
log "installing tpm"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue