diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2024-03-13 20:56:31 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-13 20:56:31 +0900 |
commit | d282a1649d7d953f028306f13d6616958f3fd1f3 (patch) | |
tree | ddab9c74f9afbf1d66f391064bb3fb8ee870cf53 /shell/completion.zsh | |
parent | 6ce8d49d1b6a38a1a7cbb02e2726956b211f46be (diff) |
Add walker options and replace 'find' with the built-in walker (#3649)
Diffstat (limited to 'shell/completion.zsh')
-rw-r--r-- | shell/completion.zsh | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/shell/completion.zsh b/shell/completion.zsh index c4ba2c75..163b0299 100644 --- a/shell/completion.zsh +++ b/shell/completion.zsh @@ -77,22 +77,19 @@ fi { # To use custom commands instead of find, override _fzf_compgen_{path,dir} -if ! declare -f _fzf_compgen_path > /dev/null; then - _fzf_compgen_path() { - echo "$1" - command find -L "$1" \ - -name .git -prune -o -name .hg -prune -o -name .svn -prune -o \( -type d -o -type f -o -type l \) \ - -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' - } -fi - -if ! declare -f _fzf_compgen_dir > /dev/null; then - _fzf_compgen_dir() { - command find -L "$1" \ - -name .git -prune -o -name .hg -prune -o -name .svn -prune -o -type d \ - -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' - } -fi +# +# _fzf_compgen_path() { +# echo "$1" +# command find -L "$1" \ +# -name .git -prune -o -name .hg -prune -o -name .svn -prune -o \( -type d -o -type f -o -type l \) \ +# -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' +# } +# +# _fzf_compgen_dir() { +# command find -L "$1" \ +# -name .git -prune -o -name .hg -prune -o -name .svn -prune -o -type d \ +# -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' +# } ########################################################### @@ -148,10 +145,19 @@ __fzf_generic_path_completion() { leftover=${leftover/#\/} [ -z "$dir" ] && dir='.' [ "$dir" != "/" ] && dir="${dir/%\//}" - matches=$(eval "$compgen $(printf %q "$dir")" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --scheme=path --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_COMPLETION_OPTS-}" __fzf_comprun "$cmd" ${(Q)${(Z+n+)fzf_opts}} -q "$leftover" | while read item; do - item="${item%$suffix}$suffix" - echo -n "${(q)item} " - done) + matches=$( + unset FZF_DEFAULT_COMMAND + export FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --scheme=path --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_COMPLETION_OPTS-}" + if declare -f "$compgen" > /dev/null; then + eval "$compgen $(printf %q "$dir")" | __fzf_comprun "$cmd" ${(Q)${(Z+n+)fzf_opts}} -q "$leftover" + else + [[ $compgen =~ dir ]] && walker=dir,follow || walker=file,dir,follow,hidden + __fzf_comprun "$cmd" ${(Q)${(Z+n+)fzf_opts}} -q "$leftover" --walker "$walker" --walker-root="$dir" < /dev/tty + fi | while read item; do + item="${item%$suffix}$suffix" + echo -n "${(q)item} " + done + ) matches=${matches% } if [ -n "$matches" ]; then LBUFFER="$lbuf$matches$tail" |