diff --git a/home_config/erdtree/.erdtree.toml b/home_config/erdtree/.erdtree.toml new file mode 100644 index 0000000..6fc53d2 --- /dev/null +++ b/home_config/erdtree/.erdtree.toml @@ -0,0 +1,39 @@ +# erdtree (erd) configuration — /home/lkraven/.config/erdtree/.erdtree.toml +# +# The top-level table below is the DEFAULT for a bare `erd`. Named tables are +# opt-in via `erd -c `. +# +# Rationale: erd ships as a disk-usage tool — its stock defaults are root-at- +# bottom, sorted by size, with a du column. That is a fine `du` replacement but +# a surprising `tree`. This config makes the bare invocation behave like GNU +# tree (root at top, name-sorted, dirs first, no size column) and moves the +# disk-usage behaviour behind `erd -c du`. +# +# Note: erd respects .gitignore by default. That is kept — it is why listing a +# repo is fast and readable. Pass `-i` to ignore .gitignore, `-.` for hidden +# files, `-. --no-git` for hidden-but-not-.git. + +# ---- default: tree-like folder listing ---- +layout = "inverted" # root at top, like GNU tree +sort = "name" # lexicographic, like GNU tree +dir-order = "first" # directories above files +suppress-size = true # no disk-usage column +no-progress = true # no progress indicator on fast listings + +# ---- `erd -c du` : the disk-usage mode erd was actually built for ---- +[du] +layout = "inverted" +sort = "rsize" # largest first +dir-order = "first" +human = true # human-readable byte sizes +disk-usage = "physical" # actual blocks on disk + +# ---- `erd -c all` : everything, nothing hidden or ignored ---- +[all] +layout = "inverted" +sort = "name" +dir-order = "first" +suppress-size = true +no-progress = true +hidden = true +no-ignore = true diff --git a/home_root/.zshrc b/home_root/.zshrc index ebe41b6..8cbd92a 100644 --- a/home_root/.zshrc +++ b/home_root/.zshrc @@ -33,6 +33,11 @@ zinit light zsh-users/zsh-autosuggestions zinit ice depth=1 zinit light jeffreytse/zsh-vi-mode +# user-local completions. Generated (not repo-tracked) completion scripts land +# in ~/.zfunc; lk-installers/install-apps writes them. Currently: _erd. +# Regenerate by hand with: erd --completions zsh > ~/.zfunc/_erd +fpath=(~/.zfunc $fpath) + # Load completions autoload -U compinit && compinit zinit cdreplay -q @@ -74,6 +79,10 @@ zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup # aliases alias cat='bat' +# erdtree — parallel directory walker; benchmarked 1.8x faster than GNU tree +# and 6.8x faster than `eza --tree` over 658k entries. Config (which makes its +# du-tool defaults behave like tree) lives in ~/.config/erdtree/.erdtree.toml. +alias tree='erd' # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh diff --git a/lk-installers/install-apps b/lk-installers/install-apps index a04c084..6508d6e 100755 --- a/lk-installers/install-apps +++ b/lk-installers/install-apps @@ -15,6 +15,16 @@ # 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 @@ -47,6 +57,11 @@ install_macos() { # 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 } @@ -89,6 +104,11 @@ install_linux() { # 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