From 616f7ba17787efc8120224b7e697c9fabf2db798 Mon Sep 17 00:00:00 2001 From: skywind3000 Date: Sat, 3 Feb 2018 14:47:33 +0800 Subject: [PATCH] update predefined --- src/strategies/predefined.zsh | 12 ++++++------ zsh-autosuggestions.zsh | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/strategies/predefined.zsh b/src/strategies/predefined.zsh index fc51bdf..0c699d5 100644 --- a/src/strategies/predefined.zsh +++ b/src/strategies/predefined.zsh @@ -23,6 +23,11 @@ _zsh_autosuggest_predefined_generate() { echo "autosuggestions is generating: $pname" + # copy builtin predefine database + local txt="${_zsh_autosuggest_script_path}/predefined.txt" + + [ -f "$txt" ] && cat "$txt" > "$pname" + # enumerate commands in $PATH and add them to ~/.zsh_autosuggest for p ("${(@s/:/)PATH}"); do cd "$p" @@ -47,11 +52,7 @@ _zsh_autosuggest_predefined_generate() { done cd "${pwd}" - print -l $suggests > "$pname" - - # copy builtin predefine database - local txt="${_zsh_autosuggest_script_path}/predefined.txt" - cat "$txt" >> "$pname" + print -l $suggests >> "$pname" } # echo "sourced predefined" @@ -61,7 +62,6 @@ _zsh_autosuggest_strategy_predefined() { setopt EXTENDED_GLOB local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}" local result="${history[(r)${prefix}*]}" - result="" if [[ $result == "" ]]; then if (( ! ${+_ZSH_AUTOSUGGEST_PREDEFINE} )); then diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index f5cf8e7..887e6dd 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -589,6 +589,11 @@ _zsh_autosuggest_predefined_generate() { echo "autosuggestions is generating: $pname" + # copy builtin predefine database + local txt="${_zsh_autosuggest_script_path}/predefined.txt" + + [ -f "$txt" ] && cat "$txt" > "$pname" + # enumerate commands in $PATH and add them to ~/.zsh_autosuggest for p ("${(@s/:/)PATH}"); do cd "$p" @@ -613,11 +618,7 @@ _zsh_autosuggest_predefined_generate() { done cd "${pwd}" - print -l $suggests > "$pname" - - # copy builtin predefine database - local txt="${_zsh_autosuggest_script_path}/predefined.txt" - cat "$txt" >> "$pname" + print -l $suggests >> "$pname" } # echo "sourced predefined" @@ -627,7 +628,6 @@ _zsh_autosuggest_strategy_predefined() { setopt EXTENDED_GLOB local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}" local result="${history[(r)${prefix}*]}" - result="" if [[ $result == "" ]]; then if (( ! ${+_ZSH_AUTOSUGGEST_PREDEFINE} )); then