commit 38156d4dfd5e193c5fe5b4e8582edb4f177d87c6 parent aadafb6e7cac915e5c9eccdbb17faf7d5815f535 Author: Chris Bracken <chris@bracken.jp> Date: Sun, 7 Jun 2026 08:05:50 +0900 zsh: cache fzf --zsh output Cache output so we don't pay the cost of regenerating this each startup. Only regenerate if the fzf binary has changed since we cached it last. Diffstat:
| M | .config/zsh/.zshrc | | | 13 | ++++++++++--- |
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc @@ -101,9 +101,16 @@ if [ -f "$XDG_CONFIG_HOME/zsh/functions" ]; then . "$XDG_CONFIG_HOME/zsh/functions" fi -# If fzf is installed, enable it. -if command -v fzf &> /dev/null; then - . <(fzf --zsh) +# If fzf is installed, enable it. Cache `fzf --zsh` output so we don't fork fzf +# on every shell startup; regenerate when the fzf binary is newer than the +# cached init script. +if (( $+commands[fzf] )); then + fzf_init="$XDG_CACHE_HOME/zsh/fzf-init.zsh" + if [[ ! -s $fzf_init || $commands[fzf] -nt $fzf_init ]]; then + fzf --zsh > $fzf_init + fi + . $fzf_init + unset fzf_init fi # Source any machine-local config.