zsh-autosuggestions icon indicating copy to clipboard operation
zsh-autosuggestions copied to clipboard

cycling through auto-suggestion history

Open jhwshin opened this issue 3 years ago • 1 comments

I was wondering if it is possible to cycle through auto-suggestions without completion?

Example history:

git checkout mybranch1

git status
git commit -m "blah blah"
git push

git checkout mybranch2

Lets say I type git ch then the auto-suggestion (in 'GRAY') would show:

git ch<GRAY>eckout mybranch2<GRAY>

Then I may press "up arrow" key to cycle through history:

git ch<GRAY>eckout mybranch1<GRAY>

Hence showing suggestion without completion.

jhwshin avatar Apr 02 '22 07:04 jhwshin

See #646, you can use bindkey.

jonasreiher avatar Jun 22 '22 11:06 jonasreiher

See #646, you can use bindkey.

When I add those lines into my .zshrc file, it doesn't seem to work as advertised.

What happens is that that if I run these commands

echo aa
echo ab
echo ac

And then I enter

echo a

I do see echo ac with c in grey as the suggestion. This is expected.

But then when I press the up arrow, it simply accepts the suggested c and I am unable to scroll up or down past echo ac.

So the suggestion is selected if I press up or right. If I press back, the cursor moves back a character but the suggestion remains. If I press down, the suggestion disappears.

Why might this be, and how can I implemented the behavior @jhwshin described?

Note:

$ bindkey -M viins | grep -e "\^\[\[[ABCD]"
"^[[A" history-beginning-search-backward
"^[[B" history-beginning-search-forward
"^[[C" vi-forward-char
"^[[D" vi-backward-char
$  bindkey -M vicmd | grep -e "\^\[\[[ABCD]"
"^[[A" history-beginning-search-backward
"^[[B" history-beginning-search-forward
"^[[C" vi-forward-char
"^[[D" vi-backward-char

cohml avatar Jul 31 '23 14:07 cohml