diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2024-05-07 19:31:13 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2024-05-07 19:31:56 +0900 |
| commit | cd8d736a9f4074de3aafdf3c10fff75cfb6c5ed0 (patch) | |
| tree | 84d100943e2dab49b7a33f007cb5e54efd6b49d2 /shell | |
| parent | 0952b2dfd48e72fa82430e4d58a923f594e43c69 (diff) | |
| download | fzf-cd8d736a9f4074de3aafdf3c10fff75cfb6c5ed0.tar.gz | |
[shell] Add $FZF_COMPLETION_{DIR,PATH}_OPTS
To allow separately overriding 'walker' options.
Close #3778
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/completion.bash | 20 | ||||
| -rw-r--r-- | shell/completion.zsh | 20 |
2 files changed, 28 insertions, 12 deletions
diff --git a/shell/completion.bash b/shell/completion.bash index 43fa46af..e01b3005 100644 --- a/shell/completion.bash +++ b/shell/completion.bash @@ -4,10 +4,12 @@ # / __/ / /_/ __/ # /_/ /___/_/ completion.bash # -# - $FZF_TMUX (default: 0) -# - $FZF_TMUX_OPTS (default: empty) -# - $FZF_COMPLETION_TRIGGER (default: '**') -# - $FZF_COMPLETION_OPTS (default: empty) +# - $FZF_TMUX (default: 0) +# - $FZF_TMUX_OPTS (default: empty) +# - $FZF_COMPLETION_TRIGGER (default: '**') +# - $FZF_COMPLETION_OPTS (default: empty) +# - $FZF_COMPLETION_PATH_OPTS (default: empty) +# - $FZF_COMPLETION_DIR_OPTS (default: empty) if [[ $- =~ i ]]; then @@ -297,8 +299,14 @@ __fzf_generic_path_completion() { if declare -F "$1" > /dev/null; then eval "$1 $(printf %q "$dir")" | __fzf_comprun "$4" -q "$leftover" else - [[ $1 =~ dir ]] && walker=dir,follow || walker=file,dir,follow,hidden - __fzf_comprun "$4" -q "$leftover" --walker "$walker" --walker-root="$dir" + if [[ $1 =~ dir ]]; then + walker=dir,follow + rest=${FZF_COMPLETION_DIR_OPTS-} + else + walker=file,dir,follow,hidden + rest=${FZF_COMPLETION_PATH_OPTS-} + fi + __fzf_comprun "$4" -q "$leftover" --walker "$walker" --walker-root="$dir" $rest fi | while read -r item; do printf "%q " "${item%$3}$3" done diff --git a/shell/completion.zsh b/shell/completion.zsh index ddf5f4bb..3634a0b1 100644 --- a/shell/completion.zsh +++ b/shell/completion.zsh @@ -4,10 +4,12 @@ # / __/ / /_/ __/ # /_/ /___/_/ completion.zsh # -# - $FZF_TMUX (default: 0) -# - $FZF_TMUX_OPTS (default: '-d 40%') -# - $FZF_COMPLETION_TRIGGER (default: '**') -# - $FZF_COMPLETION_OPTS (default: empty) +# - $FZF_TMUX (default: 0) +# - $FZF_TMUX_OPTS (default: empty) +# - $FZF_COMPLETION_TRIGGER (default: '**') +# - $FZF_COMPLETION_OPTS (default: empty) +# - $FZF_COMPLETION_PATH_OPTS (default: empty) +# - $FZF_COMPLETION_DIR_OPTS (default: empty) # Both branches of the following `if` do the same thing -- define @@ -160,8 +162,14 @@ __fzf_generic_path_completion() { 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 + if [[ $compgen =~ dir ]]; then + walker=dir,follow + rest=${FZF_COMPLETION_DIR_OPTS-} + else + walker=file,dir,follow,hidden + rest=${FZF_COMPLETION_PATH_OPTS-} + fi + __fzf_comprun "$cmd" ${(Q)${(Z+n+)fzf_opts}} -q "$leftover" --walker "$walker" --walker-root="$dir" ${(Q)${(Z+n+)rest}} < /dev/tty fi | while read item; do item="${item%$suffix}$suffix" echo -n "${(q)item} " |
