From 6de948c9c5cbb75be78a6f1323c27f9fb5ce46cd Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Fri, 22 May 2015 00:54:27 +0200 Subject: [PATCH] Add widget autosuggest-execute-suggestion It basically means this: go to the end of line (i.e. accept the suggestion) and then hit enter. --- README.md | 1 + autosuggestions.zsh | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index d6b7a98..7b0bff2 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ bindkey '^T' autosuggest-toggle List of widgets: - `autosuggest-toggle` – disable/enable autosuggestions. + - `autosuggest-execute-suggestion` – accept the suggestion and execute it. ## Configuration diff --git a/autosuggestions.zsh b/autosuggestions.zsh index 545a93a..96f5c81 100644 --- a/autosuggestions.zsh +++ b/autosuggestions.zsh @@ -250,6 +250,15 @@ autosuggest-accept-suggestion() { fi } +autosuggest-execute-suggestion() { + if [[ -n $ZLE_AUTOSUGGESTING ]]; then + zle autosuggest-end-of-line-orig + autosuggest-invalidate-highlight-cache + autosuggest-highlight-suggested-text + fi + zle .accept-line +} + autosuggest-invalidate-highlight-cache() { # invalidate the buffer for zsh-syntax-highlighting _zsh_highlight_autosuggest_highlighter_cache=() @@ -259,6 +268,7 @@ zle -N autosuggest-toggle zle -N autosuggest-start zle -N autosuggest-accept-suggested-small-word zle -N autosuggest-accept-suggested-word +zle -N autosuggest-execute-suggestion zle -N autosuggest-paused-self-insert zle -N autosuggest-insert-or-space