summaryrefslogtreecommitdiff
path: root/home-config/zsh/zsh-autosuggestions/src/fetch.zsh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--home-config/zsh/zsh-autosuggestions/src/fetch.zsh27
1 files changed, 27 insertions, 0 deletions
diff --git a/home-config/zsh/zsh-autosuggestions/src/fetch.zsh b/home-config/zsh/zsh-autosuggestions/src/fetch.zsh
new file mode 100644
index 0000000..fef2715
--- /dev/null
+++ b/home-config/zsh/zsh-autosuggestions/src/fetch.zsh
@@ -0,0 +1,27 @@
+
+#--------------------------------------------------------------------#
+# Fetch Suggestion #
+#--------------------------------------------------------------------#
+# Loops through all specified strategies and returns a suggestion
+# from the first strategy to provide one.
+#
+
+_zsh_autosuggest_fetch_suggestion() {
+ typeset -g suggestion
+ local -a strategies
+ local strategy
+
+ # Ensure we are working with an array
+ strategies=(${=ZSH_AUTOSUGGEST_STRATEGY})
+
+ for strategy in $strategies; do
+ # Try to get a suggestion from this strategy
+ _zsh_autosuggest_strategy_$strategy "$1"
+
+ # Ensure the suggestion matches the prefix
+ [[ "$suggestion" != "$1"* ]] && unset suggestion
+
+ # Break once we've found a valid suggestion
+ [[ -n "$suggestion" ]] && break
+ done
+}