mcfly icon indicating copy to clipboard operation
mcfly copied to clipboard

Inline suggestions in zsh like zsh-autosuggestions

Open cantino opened this issue 4 years ago • 6 comments

What would it take to make a zsh-autosuggestions completion hook for McFly?

cantino avatar May 24 '20 01:05 cantino

Also might be able to improve bash bindings using something like https://stackoverflow.com/questions/57811962/bind-up-arrow-key-to-fzf-command

cantino avatar May 25 '20 06:05 cantino

@cantino You might even be able to reuse zsh-autosuggestions itself. They added the ability to add “providers” to the suggestions (like inline suggestions for completions), and I think you can use that abstraction to easily add your history suggestions. (I have no further knowledge, I guess you can just open an issue and ask them.)

NightMachinery avatar Jun 15 '21 13:06 NightMachinery

Does not look very complex: https://github.com/zsh-users/zsh-autosuggestions/blob/master/src/strategies/history.zsh#L31

Could mcfly search just output all suggestions as lines instead of opening a TUI when it detects a non-tty file on stdout?

Mic92 avatar Aug 09 '21 13:08 Mic92

The hacky work around is using this:

╭─[~/.homesick/repos/dotfiles/zsh/zsh-autosuggestions]─[tags/v0.6.4]
╰─ % mcfly search --output-selection /tmp/foo1 foo </dev/null

╭─[~/.homesick/repos/dotfiles/zsh/zsh-autosuggestions]─[tags/v0.6.4]
╰─ % cat /tmp/foo1
mode display
commandline foo

however it still tries to spawn a menu for a split-second.

Mic92 avatar Aug 09 '21 14:08 Mic92

@cantino do you mean like what this does? https://github.com/Aloxaf/fzf-tab

praveenperera avatar Aug 09 '21 14:08 praveenperera

Not quite, Auto-suggestions show up without tabs.

This hacky line extracts suggestions:

$ suggestion=$(script -q -O /dev/null -c "mcfly search -o /proc/self/fd/3 test </dev/null" 3>&1 >/dev/null)
$ echo $suggestion
mode display
commandline test
$ filtered=$(echo $suggestion | grep -oP '(?<=commandline )\w+')
$ echo $filtered
test

Mic92 avatar Aug 09 '21 14:08 Mic92