I have looked around, can not find anyway to use fzf to search history in irb or pry console. Is there any way make it?
Asked
Active
Viewed 1,053 times
1 Answers
5
After a look around, I get it that command completion is associated with GNU Readline, and then I found a pure ruby implementation of Readline, in fact
It's quite easy to make fzf works in pry with RbReadline
, what I have do is overwrite the RbReadline
's class method rl_reverse_search_history
, which is triggered when we hit Ctrl + R in pry console.
Summary of what I have done:
Install rb-readline
gem install rb-readline
Modify your
.pryrc
add thisrequire 'rb-readline' def RbReadline.rl_reverse_search_history(sign, key) rl_insert_text `cat ~/.pry_history | fzf --tac | tr '\n' ' '` end
The rl_insert_text
inserts the result you selected from fzf into the terminal after your cursor.

Fangxing
- 5,716
- 2
- 49
- 53