Accept line with enter/return? #7
Thats the intended behavior. This implementation mimics fish's autosuggestions, which must be unobtrusive(it shouldn't change the way you use tab completion, just give visual hints where history or tab completion it may be used).
To accept the suggested words, two widgets are provided: autosuggest-accept-suggested-word and autosuggest-accept-suggested-small-word. I suggest you bind one of those to ctrl+f:
bindkey '^F' autosuggest-accept-suggested-small-word
I also recommend you combine this plugin with zsh-history-substring-search(https://github.com/zsh-users/zsh-history-substring-search). You can then accept the entire suggestion by simply pressing arrow up.
If you really want to have text inserted without pressing anything, try zsh's builtin predict-on widget:
autoload predict-on
zle-line-init() {
predict-on
}
zle -N zle-line-init
I tried predict-on before and I liked its behavior. Its only downside (really, the only thing which bugged me) was that I couldn't "style" the suggestion (e.g. color everything right from the cursor). Thank you for your explanation.
Ok but it should be really easy to modify predict-on to add highlighting to the suggested part, just add hooks arround its intercepted widgets(self-insert, backward-delete-char) to highlight everything in RBUFFER, just like this plugin does. Look into this plugin source code for clues
I tried your suggestion to use the zsh-history-substring-search plugin.
I type cd Scr and the suggestion becomes cd Scripts/bin.
I then press the "up" arrow key to accept this, but instead it changes to another, completely unrelated command from history. What could be wrong?
Hi tarruda,
thanks for your plugin. I'm quite new to zsh and maybe I did something wrong, but I expected to accept a suggested line via enter/return. Instead the suggestion was removed and I accepted everything before the suggestion. I commented out two lines (https://github.com/tarruda/zsh-autosuggestions/blob/master/autosuggestions.zsh#L36, https://github.com/tarruda/zsh-autosuggestions/blob/master/autosuggestions.zsh#L147) to get my desired effect. Can I get the same effect somehow without modifying the source?