2bc5b56ff9
erdtree (erd) replaces GNU tree as the tree-style directory lister. It uses a parallel walker (the `ignore` crate, one thread per core) where GNU tree is strictly serial. Benchmarked over 658k entries under ~/development, best-of-3, warm cache, plain output, hidden included, gitignore off: erd (16 threads) 2.35s GNU tree 2.1.0 4.22s (1.8x slower) erd (1 thread) 4.97s (so ~2.1x thread scaling) eza --tree 15.87s (6.8x slower) Three changes: - home_config/erdtree/.erdtree.toml — erd ships as a disk-usage tool, so its stock defaults are root-at-bottom, size-sorted, with a du column. The top-level table overrides that to behave like GNU tree; `erd -c du` keeps the original behaviour and `erd -c all` disables the gitignore/hidden filtering. Stowed to ~/.config/erdtree. - home_root/.zshrc — `alias tree='erd'`, plus ~/.zfunc prepended to fpath for the generated completion. The fpath line goes before the primary compinit at the top of the file rather than adding a third compinit call after it. - lk-installers/install-apps — erd is now a runtime assumption of the dotfiles (the alias depends on it), so a fresh box must get it: brew on macOS, cargo on Linux (not packaged in Debian apt). The zsh completion is generated per installed version rather than tracked, matching how the other generated completions in this repo are handled. Caveat worth knowing: erd respects .gitignore by default, which GNU tree does not. `-i` disables it, `-.` shows hidden files.
121 lines
4.9 KiB
Bash
Executable File
121 lines
4.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Host-aware installer for every CLI tool the dotfiles assume at runtime.
|
|
#
|
|
# macOS -> Homebrew (bootstraps Homebrew itself if missing)
|
|
# Linux -> apt (Debian/Ubuntu) + upstream installers for tools not in apt
|
|
#
|
|
# zinit and all zsh plugins (powerlevel10k, zsh-autosuggestions,
|
|
# zsh-syntax-highlighting, zsh-completions, zsh-vi-mode, fzf-tab) bootstrap
|
|
# themselves from ~/.zshrc on first shell start — they are NOT installed here.
|
|
#
|
|
# Idempotent: re-running only fills gaps. Pairs with ./link-dotfiles, or run
|
|
# `./link-dotfiles --apps` to install then link in one shot.
|
|
#
|
|
# Consolidates the former macinstaller / install-apt-pkgs / install-tools /
|
|
# install-zellij scripts.
|
|
set -euo pipefail
|
|
|
|
# erdtree (`erd`) — .zshrc aliases `tree` to it, so it is a runtime assumption
|
|
# of the dotfiles, not an optional extra. Its zsh completion is generated per
|
|
# installed version rather than tracked in the repo; .zshrc prepends ~/.zfunc
|
|
# to fpath to pick it up.
|
|
generate_erd_completion() {
|
|
command -v erd >/dev/null 2>&1 || return 0
|
|
mkdir -p "$HOME/.zfunc"
|
|
erd --completions zsh > "$HOME/.zfunc/_erd"
|
|
}
|
|
|
|
# fzf-git.sh is a sourced helper (not a package) — same on every platform.
|
|
clone_fzf_git() {
|
|
if [ -d "$HOME/fzf-git.sh" ]; then
|
|
echo "fzf-git.sh already cloned — skipping"
|
|
else
|
|
git clone --depth 1 https://github.com/junegunn/fzf-git.sh.git "$HOME/fzf-git.sh"
|
|
fi
|
|
}
|
|
|
|
install_macos() {
|
|
if ! command -v brew >/dev/null 2>&1; then
|
|
echo "Homebrew not found — installing…"
|
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
if [ -x /opt/homebrew/bin/brew ]; then eval "$(/opt/homebrew/bin/brew shellenv)"
|
|
elif [ -x /usr/local/bin/brew ]; then eval "$(/usr/local/bin/brew shellenv)"
|
|
fi
|
|
fi
|
|
|
|
echo "Installing CLI tools via Homebrew…"
|
|
brew install \
|
|
zsh git curl wget stow \
|
|
bat fd fzf zoxide \
|
|
zellij neovim btop htop fastfetch
|
|
# tldr is deprecated upstream — best-effort so a dead formula can't abort the
|
|
# run. tlrc is the maintained `tldr` client.
|
|
brew install tlrc || brew install tldr || echo "tldr unavailable — skipping"
|
|
|
|
# fzf key-bindings + completion -> ~/.fzf.zsh (sourced by .zshrc). These flags
|
|
# make it non-interactive; --no-update-rc stops it editing .zshrc (the repo
|
|
# owns that file).
|
|
"$(brew --prefix)/opt/fzf/install" --key-bindings --completion --no-update-rc >/dev/null
|
|
|
|
# erdtree: brew formula, cargo as fallback if the formula ever disappears.
|
|
command -v erd >/dev/null 2>&1 || brew install erdtree || cargo install erdtree \
|
|
|| echo "erdtree unavailable — the \`tree\` alias will not work"
|
|
generate_erd_completion
|
|
|
|
clone_fzf_git
|
|
}
|
|
|
|
install_linux() {
|
|
if ! command -v apt >/dev/null 2>&1; then
|
|
echo "error: Linux app install targets Debian/Ubuntu (apt). Install the tools manually on this distro." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Installing base packages via apt…"
|
|
sudo apt update
|
|
sudo apt install -y --no-install-recommends \
|
|
neovim vim-nox btop htop curl wget tldr git zip unzip stow zsh cargo \
|
|
zsh-autosuggestions zsh-syntax-highlighting
|
|
sudo apt install -y --no-install-recommends rar unrar || true
|
|
# fastfetch (modern neofetch); falls back to neofetch on older distros.
|
|
sudo apt install -y fastfetch || sudo apt install -y neofetch || echo "fastfetch/neofetch unavailable — skipping"
|
|
|
|
# fzf (vendored under ~/.cache/lk-tools/fzf; .zshrc adds its bin to PATH)
|
|
if [ ! -d "$HOME/.cache/lk-tools/fzf" ]; then
|
|
git clone --depth 1 https://github.com/junegunn/fzf.git "$HOME/.cache/lk-tools/fzf"
|
|
"$HOME/.cache/lk-tools/fzf/install" --key-bindings --completion --no-update-rc
|
|
fi
|
|
clone_fzf_git
|
|
|
|
# zoxide (upstream installer -> ~/.local/bin, already on PATH)
|
|
command -v zoxide >/dev/null 2>&1 || \
|
|
curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh
|
|
|
|
# bat + fd: upstream .deb so the binaries are named `bat`/`fd` (Debian ships
|
|
# them as `batcat`/`fdfind`). amd64 assumed — adjust the URLs on arm64 boxes.
|
|
if ! command -v bat >/dev/null 2>&1; then
|
|
wget -qO /tmp/bat.deb https://github.com/sharkdp/bat/releases/download/v0.24.0/bat_0.24.0_amd64.deb
|
|
sudo apt install -y /tmp/bat.deb
|
|
fi
|
|
if ! command -v fd >/dev/null 2>&1; then
|
|
wget -qO /tmp/fd.deb https://github.com/sharkdp/fd/releases/download/v10.1.0/fd_10.1.0_amd64.deb
|
|
sudo apt install -y /tmp/fd.deb
|
|
fi
|
|
|
|
# zellij: cargo build, fall back to apt
|
|
command -v zellij >/dev/null 2>&1 || cargo install zellij || sudo apt install -y zellij
|
|
|
|
# erdtree: not packaged in Debian apt, so cargo only (apt installs cargo above).
|
|
command -v erd >/dev/null 2>&1 || cargo install erdtree \
|
|
|| echo "erdtree unavailable — the \`tree\` alias will not work"
|
|
generate_erd_completion
|
|
}
|
|
|
|
case "$(uname -s)" in
|
|
Darwin) install_macos ;;
|
|
Linux) install_linux ;;
|
|
*) echo "error: unsupported OS '$(uname -s)'." >&2; exit 1 ;;
|
|
esac
|
|
|
|
echo "Done. Open a new shell (or 'exec zsh') to pick everything up."
|