From f6a7c5b957425594f2dddb897ce56c05bfc451c7 Mon Sep 17 00:00:00 2001 From: John Stegeman Date: Wed, 30 Sep 2026 07:24:23 -0400 Subject: [PATCH 1/3] fix fzf preview under non-POSIX login shells (e.g. fish) fzf runs --preview commands with $SHELL -c. ze.sh built the preview in POSIX shell syntax (pathname={2..}; ...), so with fish as the login shell the preview died before running: fish: Unsupported use of '='. In fish, please use 'set pathname ...' Two independent changes, per maintainer feedback: * Interpolate the field placeholder directly ({2..}) instead of first assigning it to a shell variable. fzf already single-quotes placeholder expansions, so this is equivalent and keeps the preview free of any shell-specific assignment syntax (works on any fzf, incl. Debian/Ubuntu versions older than 0.48 that lack --with-shell). * Pin SHELL=/bin/sh on both fzf calls, so the preview is spawned by a POSIX shell regardless of the user's login shell. This also stops the interactive shell's functions/aliases from leaking into the preview (e.g. a fish 'ls' function wrapping eza, which rejects -C). --- ze.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ze.sh b/ze.sh index 702adf0..d07f51f 100644 --- a/ze.sh +++ b/ze.sh @@ -169,7 +169,7 @@ function _ze_pick { ## mode } function _ze_find { ## pattern typ [dirs|files] [cflag] - typeset metric header mode=${3:-dirs} preview='pathname={2..}' + typeset metric header mode=${3:-dirs} typeset -a fzfopts zopts; zopts=(-l) ((${4:-0})) && zopts+=(-c) # pass -c on to the nested _ze -l call case $2 in @@ -178,8 +178,8 @@ function _ze_find { ## pattern typ [dirs|files] [cflag] *) metric='EMS score';; esac case $mode in - files) preview+='; head -256 -- "$pathname"'; zopts+=(-o);; - *) preview+='; LC_ALL=C ls -AC --color=always "$pathname"';; + files) preview='head -256 -- {2..}'; zopts+=(-o);; + *) preview='LC_ALL=C ls -AC --color=always {2..}';; esac if [[ ${_ZE_NO_FZF:-} ]] || ! command -v fzf > /dev/null; then @@ -189,7 +189,7 @@ function _ze_find { ## pattern typ [dirs|files] [cflag] header="${mode%s} stack ranked by $metric" fzfopts=( -0 -e --no-sort --preview-window='top,19%' --header="$header" --color='header:bright-red' --preview "$preview" ) (set -o pipefail; _ze "${zopts[@]}" -- "$1" | cut -f2- | - awk '{ buf[NR] = $0 } END { offs = NR+1; while (NR) print offs-NR "\t" buf[NR--] }' | fzf "${fzfopts[@]}" | cut -f2-) + awk '{ buf[NR] = $0 } END { offs = NR+1; while (NR) print offs-NR "\t" buf[NR--] }' | SHELL=/bin/sh fzf "${fzfopts[@]}" | cut -f2-) fi } @@ -202,7 +202,7 @@ function _ze_dig { ## dirs|files [fdopts_and_args] else printf '%s\n' "'fd' not found" >&2; return 1 fi - typeset fdtype=d preview='pathname={2..}' + typeset fdtype=d typeset -a fdargs; fdargs=(-Ipa) typeset -a filter; filter=(cat) case $mode in @@ -212,8 +212,8 @@ function _ze_dig { ## dirs|files [fdopts_and_args] block+='|wav|flac|woff|woff2|ttf|otf|eot|so|o|a|dylib|dll|exe|class|pyc|pyo|jar|war' block+=')$' filter=(grep -viE "$block") - preview+='; head -256 -- "$pathname"';; - *) preview+='; LC_ALL=C ls -AC --color=always "$pathname"';; + preview='head -256 -- {2..}';; + *) preview='LC_ALL=C ls -AC --color=always {2..}';; esac fdargs+=(-t"$fdtype" "$@") # shellcheck disable=SC2124 # this scalar assignment ensures join by single space independent of IFS @@ -223,7 +223,7 @@ function _ze_dig { ## dirs|files [fdopts_and_args] else typeset -a fzfopts fzfopts=( -0 -e --no-sort --preview-window='top,19%' --header="$fdex $argstring" --color='header:bright-red' --preview "$preview" ) - (set -o pipefail; $fdex "${fdargs[@]}" | LC_ALL=C "${filter[@]}" | LC_ALL=C sort | nl | fzf "${fzfopts[@]}" | cut -f2-) + (set -o pipefail; $fdex "${fdargs[@]}" | LC_ALL=C "${filter[@]}" | LC_ALL=C sort | nl | SHELL=/bin/sh fzf "${fzfopts[@]}" | cut -f2-) fi } From 7787da2a5c1929fecf37518e4983199af5221a61 Mon Sep 17 00:00:00 2001 From: John Stegeman Date: Wed, 30 Sep 2026 09:41:22 -0400 Subject: [PATCH 2/3] declare preview Co-authored-by: jghub --- ze.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ze.sh b/ze.sh index d07f51f..b16b562 100644 --- a/ze.sh +++ b/ze.sh @@ -169,7 +169,7 @@ function _ze_pick { ## mode } function _ze_find { ## pattern typ [dirs|files] [cflag] - typeset metric header mode=${3:-dirs} + typeset metric header mode=${3:-dirs} preview typeset -a fzfopts zopts; zopts=(-l) ((${4:-0})) && zopts+=(-c) # pass -c on to the nested _ze -l call case $2 in From 9bd0901af59b405ba7b8dfae86a78424784548ed Mon Sep 17 00:00:00 2001 From: John Stegeman Date: Wed, 30 Sep 2026 09:41:35 -0400 Subject: [PATCH 3/3] declare preview Co-authored-by: jghub --- ze.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ze.sh b/ze.sh index b16b562..6cbb615 100644 --- a/ze.sh +++ b/ze.sh @@ -202,7 +202,7 @@ function _ze_dig { ## dirs|files [fdopts_and_args] else printf '%s\n' "'fd' not found" >&2; return 1 fi - typeset fdtype=d + typeset fdtype=d preview typeset -a fdargs; fdargs=(-Ipa) typeset -a filter; filter=(cat) case $mode in