Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom key bindings/commands #378

Closed
jandamm opened this issue Mar 5, 2020 · 3 comments
Closed

Custom key bindings/commands #378

jandamm opened this issue Mar 5, 2020 · 3 comments

Comments

@jandamm
Copy link

jandamm commented Mar 5, 2020

Hey there,
nice project! I really enjoy using it.

Is there a way to change key bindings?
In particular I'd be interested in a different C-p/n command.

In my zsh shell I've mapped C-p to backwards history search. So pressing C-p after typing a would result in the last command starting with a instead of the previous command.
Is there something similar?
(I probably should train myself to use C-r anyways, but still 😉)

Cheers
Jan

@georgebrock
Copy link
Collaborator

gitsh uses GNU Readline as its line editor, which can be configured with a $HOME/.inputrc file.

In your case, I think you might be looking for something like:

"\C-p": history-search-backward
"\C-n": history-search-forward

Note that settings in your .inputrc file will apply to all programs that use GNU Readline, which seems to be the majority of interactive shells (notable exceptions are zsh, which has its own line editor called ZLE; and any program compiled against libedit, which is theoretically compatible with Readline but only provides a subset of the features and is especially common on macOS).

If you want to make this configuration apply only in gitsh, you can wrap it in a conditional:

$if gitsh
    "\C-p": history-search-backward
    "\C-n": history-search-forward
$endif

See the readline(3) and gitsh(1) manual pages for more information.

@georgebrock
Copy link
Collaborator

Given that this is already supported, I'm going to close the issue, but feel free to re-open if you think there's some missing functionality here.

@jandamm
Copy link
Author

jandamm commented Mar 21, 2020

Thanks for the help.
I've never really used bash and went straight to zsh (for my interactive shell) so I wasn't aware of inputrc.
Now I even got my vi keybindings 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants