Accept line with enter/return? #7

Closed
donaldpipowitch opened this Issue Nov 7, 2013 · 5 comments

3 participants

@donaldpipowitch

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?

@tarruda

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
@donaldpipowitch

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.

@tarruda

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

@shrx

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?

@tarruda

@shrx this is a separate issue, could you open and detail the error?

@shrx shrx referenced this issue in zsh-users/zsh-history-substring-search Jan 5, 2014
Closed

Wrong results with zsh-autosuggestions #28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment