From 9916799a0d0b3032fc71ece72303f1f7b49ea010 Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri Date: Sun, 22 Mar 2026 01:40:07 -0500 Subject: [PATCH] utility: Avoid multiple `ls --version` calls per shell startup --- modules/utility/init.zsh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index a38150d..cacd8be 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -76,7 +76,9 @@ if zstyle -T ':prezto:module:utility' safe-ops; then fi # ls -if [[ ${(@M)${(f)"$(ls --version 2>&1)"}:#*(GNU|lsd|uutils) *} ]]; then +_ls_version="$(ls --version 2>&1)" + +if [[ ${(@M)${(f)_ls_version}:#*(GNU|lsd|uutils) *} ]]; then # GNU Core Utilities if zstyle -T ':prezto:module:utility:ls' dirs-first; then @@ -123,10 +125,12 @@ alias lt='ll -tr' # Lists sorted by date, most recent last. alias lc='lt -c' # Lists sorted by date, most recent last, shows change time. alias lu='lt -u' # Lists sorted by date, most recent last, shows access time. -if [[ ${(@M)${(f)"$(ls --version 2>&1)"}:#*GNU *} ]]; then +if [[ ${(@M)${(f)_ls_version}:#*GNU *} ]]; then alias lx='ll -XB' # Lists sorted by extension (GNU only). fi +unset _ls_version + # Grep if zstyle -t ':prezto:module:utility:grep' color; then export GREP_COLOR=${GREP_COLOR:-'37;45'} # BSD.