bnprks / mcfly-fzf

Integrate Mcfly with fzf to combine a solid command history database with a widely-loved fuzzy search UI
MIT License
42 stars 3 forks source link

Bind entry deletion #2

Open ramnes opened 1 year ago

ramnes commented 1 year ago

Hey there, thank you for the very nice tool, awesome work. :)

The README says that "To delete history entries, run mcfly search manually". Is there anything fundamentally blocking us to use mcfly entry deletion directly from fzf?

If not, is it something that you would see into mcfly-fzf? How hard would that be?

bnprks commented 1 year ago

I think the main challenge with deletion in the fzf interface is handling confirmations well, so that users get a confirmation prompt before permanently deleting a history entry. Though looking at the fzf docs I think that the execute action may be able to handle confirmation.

In that case, the elements would be

  1. Find/make a CLI one-liner that can delete a history entry with command-line confirmation (e.g. y/n prompt). This would likely require writing a little rust code and adding a new subcommand to mcfly-fzf, and reading the mcfly code to find what function to call to perform a deletion
  2. Add a key-binding to the fzf setup scripts that will call that command appropriately

For prototyping, I'd recommend you start with 2 and make a dummy python script or something to make sure that the UI of prompt + confirm will work well, and ensure that you are able to get the relevant information passed to the CLI script.

Definitely something I'd be happy to take a pull request on if you can get it working

ramnes commented 1 year ago

FWIW I don't like McFly's confirmation in the first place. What do you think of skipping the confirmation in a first iteration, disabling the shortcut by default and adding an environment variable flag, e.g. MCFLY_FZF_UNSAFE_DELETE=1? Then we could see to eventually add the confirmation and make it activated by default.

bnprks commented 1 year ago

Yeah, disabled by default but no confirmation sounds good to me. I'll take a look at your pull over the next few days as I have time. I'm also a bit of a rust noob, but I've found tinkering on projects like mcfly and reedline to be a good learning experience