From 79b647662e2882bd0ca6a9aa494ce3948d424236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Troels=20Bj=C3=B8rnskov?= Date: Tue, 18 Jul 2023 22:29:28 +0200 Subject: [PATCH 1/3] add fuzzy matching completion this commit adds a kind of fuzzy matching to zsh. example: zshz -> agkozak/zsh-z this was not possible before. --- _zshz | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_zshz b/_zshz index a493f35..97a1f8d 100644 --- a/_zshz +++ b/_zshz @@ -55,7 +55,7 @@ emulate -L zsh local completions expl completion local -a completion_list -completions=$(zshz --complete ${(@)words:1}) +completions=$(zshz --complete ${(j: :)${(s::)${${(@)words:1}// /}}}) [[ -z $completions ]] && return 1 for completion in ${(f)completions[@]}; do From df4605d6b79210c671c93de8e647ab8cc338c545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Troels=20Bj=C3=B8rnskov?= Date: Wed, 19 Jul 2023 23:17:03 +0200 Subject: [PATCH 2/3] improve matching new approach: we first try matching whole words as in the original and fall back to fuzzy if there are no matches --- _zshz | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_zshz b/_zshz index 97a1f8d..0ce8f0e 100644 --- a/_zshz +++ b/_zshz @@ -55,7 +55,8 @@ emulate -L zsh local completions expl completion local -a completion_list -completions=$(zshz --complete ${(j: :)${(s::)${${(@)words:1}// /}}}) +completions=$(zshz --complete ${(@)words:1}) +[[ -z $completions ]] && completions=$(zshz --complete ${(j: :)${(s::)${${(@)words:1}// /}}}) [[ -z $completions ]] && return 1 for completion in ${(f)completions[@]}; do From fa5dfc055e15bfd776f753b7800b34e185552f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Troels=20Bj=C3=B8rnskov?= Date: Mon, 24 Jul 2023 10:46:31 +0200 Subject: [PATCH 3/3] use fuzzy always always use fuzzy but let the full strings take precedence over the fuzzy matches --- _zshz | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_zshz b/_zshz index 0ce8f0e..daa3618 100644 --- a/_zshz +++ b/_zshz @@ -56,7 +56,7 @@ local completions expl completion local -a completion_list completions=$(zshz --complete ${(@)words:1}) -[[ -z $completions ]] && completions=$(zshz --complete ${(j: :)${(s::)${${(@)words:1}// /}}}) +completions+=$(zshz --complete ${(j: :)${(s::)${${(@)words:1}// /}}}) [[ -z $completions ]] && return 1 for completion in ${(f)completions[@]}; do