cantino / mcfly

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

use c-m instead of c-j for return key #104

Closed Konfekt closed 3 years ago

Konfekt commented 3 years ago

The latter key is less likely to be rebound.

To avoid all these binding conflicts, one could think about a function f and a binding bind -x "'\C-r': f"instead

cantino commented 3 years ago

Thanks @Konfekt! This seems to work fine for me. Can you explain what the difference between c-m and c-j are, conceptually? Will this break anything for folks?

Konfekt commented 3 years ago

In Vim c-m is mapped to CR(\n) whereas c-j is mapped to NL (\r). In .inputrc one can bind c-j to a command different from that of CR, but not c-m According to https://stackoverflow.com/a/14619214

Enter is usually equivalent to C-m. But, if the icrnl flag is active for the tty (see stty -a), then an input C-m will automatically be translated to C-j.

Therefore, mapping it to c-m is likely to cause fewer collisions.

As an alternative independent of key bindings, there is

f() { mcfly search; }
bind -x "'\C-r': f"

where probably bind -x has been around for a while, at least since 2014.

cantino commented 3 years ago

Thanks for the explanation! Let's start with this and then we can try to move to bind -x to fix #mcfly: showing up in the history. See #105

Konfekt commented 2 years ago

Somehow mcfly now (at least since version >= 5.12) in both ZSH and Bash maps Ctrl-J to Ctrl-M; it might be a change in a terminal input library, supposedly when the optional Vim key bindings were added? Previously in Bash inputrc was respected.

cantino commented 2 years ago

Locally I just did ctrl-j and it accepted the selection. What did it do before?

Konfekt commented 2 years ago

That depended on the value of "\C-j" in ~/.inputrc; if not set to accept-line it would not accept the selection

cantino commented 2 years ago

I don't think that's true. It's explicitly bound to accept the selection, or am I missing something? https://github.com/cantino/mcfly/blob/874441b6bcdc5292375da654fd131146f547a8a4/src/interface.rs#L518

On Tue, Feb 15, 2022 at 8:55 PM Konfekt @.***> wrote:

That depended on the value of "\C-j" in ~/.inputrc; if not set to accept-line it would not accept the selection

— Reply to this email directly, view it on GitHub https://github.com/cantino/mcfly/pull/104#issuecomment-1041107416, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAUO65BVORNC7FMOYM6OSDU3MU3RANCNFSM4SLB2XOQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you modified the open/close state.Message ID: @.***>

Konfekt commented 2 years ago

You are right. I am sorry; my memory failed me. This pull request was about how to trigger mcfly by a bash binding. Indeed Ctrl-J was always bound to accept the selection in interface.rs and never configurable as in say fzf. So this remark could be rather considered a (timid) feature request than the observation of a recession.

cantino commented 2 years ago

No worries! I'd be open to someone upgrading McFly to use .inputrc.