cantino / mcfly

Fly through your shell history. Great Scott!
MIT License
6.96k stars 178 forks source link

Inline suggestions in zsh like zsh-autosuggestions #85

Open cantino opened 4 years ago

cantino commented 4 years ago

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

cantino commented 4 years ago

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

NightMachinery commented 3 years ago

@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.)

Mic92 commented 3 years ago

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 commented 3 years ago

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.

praveenperera commented 3 years ago

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

Mic92 commented 3 years ago

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