Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fzf fuzzy search to REPL #204

Closed
Moelf opened this issue Jul 4, 2020 · 4 comments
Closed

Add fzf fuzzy search to REPL #204

Moelf opened this issue Jul 4, 2020 · 4 comments

Comments

@Moelf
Copy link
Contributor

Moelf commented Jul 4, 2020

Love using OhMyREPL, but I miss the Ctrl-r fuzzy search to find a command that is 10 lines away or yesterday, the original fzf package can be found here.

I already made fzf_jll and a wrapper module for it that can interactively search repl_history.jl (inter_fzf(Fzf.read_repl_hist())).

Wondering if this is a welcome enhancement, and if so where should I add this (key-binding / result substitution)

Thx!

@KristofferC
Copy link
Owner

That's a cool idea. I use fzf a lot as well. Not sure what the best keybinding is, perhaps it should just replace the defalt Ctrl+r?

@Moelf
Copy link
Contributor Author

Moelf commented Jul 5, 2020

yeah, that's how fzf usually works in terminal emulators anyway, since it's strictly better (~100%) than default Ctrl+r I think it's appropriate to introduce it here

@Moelf
Copy link
Contributor Author

Moelf commented Jul 9, 2020

ah ok, so I hacked together a working prototype: https://streamable.com/jxdjx9
key binding is ctrl-f
setup:

]add JLFzf

then the following in startup.jl:

import REPL
import REPL.LineEdit
using JLFzf

const mykeys = Dict{Any,Any}(
    "^f" => function (s,o,c)
        b = JLFzf.read_repl_hist() |> inter_fzf;
        LineEdit.edit_insert(Base.active_repl.mistate, b)
    end,
)

function customize_keys(repl)
    repl.interface = REPL.setup_interface(repl; extra_repl_keymap = mykeys)
end

atreplinit(customize_keys)

@KristofferC
Copy link
Owner

Landed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants