@@ -271,12 +271,34 @@ ZPY_PROCS=${${$(nproc 2>/dev/null):-$(sysctl -n hw.logicalcpu 2>/dev/null)}:-4}
271271 REPLY="${ZPY_VENVS_HOME}/${REPLY}"
272272}
273273
274+ .zpy_fzf_cmd () {
275+ emulate -L zsh
276+ unset REPLY
277+
278+ local fzf_cmd=fzf
279+ if (( $+commands[fzf] )) {
280+ REPLY=fzf
281+ } elif (( $+commands[sk] )) {
282+ REPLY=sk
283+ } else {
284+ .zpy_log error \
285+ 'zpy selection operations require a filter tool' 'Any one of:' \
286+ '- fzf' \
287+ '- sk (skim)'
288+ .zpy_log tip Suggestion "Install fzf with your distro's package manager."
289+ return 1
290+ }
291+ }
292+
274293.zpy_chooseproj () { # [--multi]
275294 emulate -L zsh
276295 [[ $ZPY_VENVS_HOME ]] || return
277296
278297 # TODO: should this absorb .zpy_pipzchoosepkg?
279298
299+ .zpy_fzf_cmd || return
300+ local fzf_cmd=$REPLY
301+
280302 local multi fzf_args=(--reverse -0 --preview='<{}/*.in')
281303 if [[ $1 == --multi ]] {
282304 unset reply
@@ -291,7 +313,7 @@ ZPY_PROCS=${${$(nproc 2>/dev/null):-$(sysctl -n hw.logicalcpu 2>/dev/null)}:-4}
291313 local projdirs=(${ZPY_VENVS_HOME}/*/project(@N-/:P))
292314 reply=(${(f)"$(
293315 print -rln -- $projdirs \
294- | fzf $fzf_args
316+ | $fzf_cmd $fzf_args
295317 )"})
296318
297319 [[ $reply ]] || return
@@ -1827,6 +1849,9 @@ jsonfile.write_text(dumps(data, indent=4))
18271849 # TODO: fzf OR skim OR fzy OR peco
18281850 [[ -r $ZPY_SRC ]] || return
18291851
1852+ .zpy_fzf_cmd || return
1853+ local fzf_cmd=$REPLY
1854+
18301855 local fzf_args=() fzf_header fzf_prompt multi
18311856 fzf_args=(--reverse -0)
18321857 fzf_header='Packages:'
@@ -1856,7 +1881,7 @@ jsonfile.write_text(dumps(data, indent=4))
18561881
18571882 local pkgs=($1/*(N/:t))
18581883 reply=(${(f)"$(
1859- print -rln -- $pkgs | fzf $fzf_args
1884+ print -rln -- $pkgs | $fzf_cmd $fzf_args
18601885 )"})
18611886
18621887 [[ $reply ]] || return
@@ -1919,7 +1944,7 @@ jsonfile.write_text(dumps(data, indent=4))
19191944
19201945 zf_mkdir -p $bins_home
19211946
1922- local pkgname projdir vpath bins bin src dest REPLY
1947+ local pkgname projdir vpath bins bin src dest REPLY fzf_cmd
19231948 for 1 {
19241949 .zpy_pkgspec2name $1 || return
19251950 pkgname=$REPLY
@@ -1933,6 +1958,9 @@ jsonfile.write_text(dumps(data, indent=4))
19331958 if [[ $bins_showlist ]] {
19341959 bins=(${bins:*bins_showlist})
19351960 } else {
1961+ .zpy_fzf_cmd || return
1962+ fzf_cmd=$REPLY
1963+
19361964 bins=(${bins:|bins_hidelist})
19371965 bins=(${bins:#([aA]ctivate(|.csh|.fish|.ps1|.bat|.nu|_this.py)|(deactivate|pydoc).bat|easy_install(|-<->*)|(pip|python|pypy)(|<->*)|*.so|__pycache__)})
19381966 if [[ $pkgname != pip-tools ]] bins=(${bins:#pip-(compile|sync)})
@@ -1941,7 +1969,7 @@ jsonfile.write_text(dumps(data, indent=4))
19411969 if [[ $pkgname != build ]] bins=(${bins:#pyproject-build})
19421970 bins=(${(f)"$(
19431971 print -rln $bins \
1944- | fzf $fzf_args --header="$fzf_header $1 . . ." \
1972+ | $fzf_cmd $fzf_args --header="$fzf_header $1 . . ." \
19451973 --prompt='Which scripts should be added to the path? Choose one with <enter> or more with <tab>. '
19461974 )"})
19471975 }
0 commit comments