By wrapping the fzf (fzf_jll and JLFzf) (I realize it should probably just be called Fzf.jl but name is then too short (since potentially one can make a julia implementation of Fzf)
Ctrl-f is already used for forward one character (as in emacs). I install your package and the gist, and find that Ctrl-f still does forward one character rather than fuzzy history search. Am I missing something?
(btw. I have successfully ignored config chores in favor of work today, but was unable to resist here.)
I see. I looks like I have to choose something that is not already bound. In my case ^q works. But, I’m using default keybindings (linux, if that matters). fzf errors out complaining that the list (my repl history) is too long (190K lines). If I delete repl_history.jl then your package + init code do work !
using InteractiveCodeSearch
InteractiveCodeSearch.CONFIG.interactive_matcher = `fzf`
@search show # search method definitions of show
@searchmethods 1 # search methods defined for integer
@searchhistory # search history
If you have pygmentize, you can have multi-line preview with syntax highlighting:
thanks to @denius , using Julia’s IOBuffer solved the problem of “repl history too long”. Also now that when selecting a entry, the prompt mode will be switched automatically (i.e to Pkg> or help> or shell> etc.)
Many thanks for this. I tried to incorporate it into my startup.jl but got an error because of a comma missing at the end of line 9 in your gist.
Also, my startup.jl looks like this:
atreplinit() do repl
try
@info "importing JLFzf"
@eval import REPL
@eval import REPL.LineEdit
@eval import JLFzf
mykeys = Dict{Any,Any}(
# primary history search: most recent first
"^R" => function (mistate, o, c)
line = JLFzf.inter_fzf(JLFzf.read_repl_hist(),
"--read0",
"--tiebreak=index",
"--height=80%");
JLFzf.insert_history_to_repl(mistate, line)
end,
)
function customize_keys(repl)
repl.interface = REPL.setup_interface(repl; extra_repl_keymap = mykeys)
end
customize_keys(repl)
catch e
@error "error while importing JLFzf" e
end
# similar blocks for other packages that are imported at startup...
end
I had to remove the const in the declaration of mykeys because Julia complained that
ERROR: LoadError: syntax: unsupported `const` declaration on local variable
How would one may mykeys a const in a case like this?
ah, sorry about the typo. Btw, now Fzf is integrated with OhMyREPL, you can use that and make startup.jl cleaner . If it’s not in global scope, it’s fine for not being const I guess.