cantino / mcfly

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

Option to configure custom shell key binding? #198

Open varenc opened 2 years ago

varenc commented 2 years ago

I'm just trying out mcfly and love it so far, but I don't want to fully commit to it yet. I'd like to keep using it side-by-side with my fzf history searcher.

I discovered there's no easy way to change the shell key bindings. And because the init script is returned from the mcfly binary I can't change it there without recompiling.

My solution for now is to init mcfly, then just redefine my key binding the way I like it like this:

eval "$(mcfly init zsh)"
bindkey "^R" fzf-history-widget       # Ctrl+R binds to fzf searcher
bindkey '^[^R' mcfly-history-widget   # Ctrl+Alt+R binds to mcfly

Which totally works, but a mcfly option to define the key binding would be nice! Albeit, that might be a bit too niche and people like me that care can work around it easily enough.

Cheers

cantino commented 2 years ago

That's a very reasonable request, although your solution is pretty simple too. Do you think the configuration would be part of the init call?

varenc commented 2 years ago

like eval "$(mcfly init zsh '^[^R')" or something, where it's an optional parameter? That totally works, though my pref would just be for yet-another environmental var, perhaps MCFLY_SHELL_BINDING='^[^R', for consistency with the other config options.

Though also if I'm the only person that's ever indicated they want this, then I don't think it's worth adding. Not everything needs to be an option. If anyone else agrees hopefully they'll find this issue and chime in!

Zebradil commented 2 years ago

I also want to have different binding for mcfly. But fo me it will be fine to just re-bind as suggested by @varenc. Maybe just put this as an example into the readme?

cantino commented 2 years ago

I think just documentation is reasonable. Would you mind adding it to the README?