Antoine Gallix
Antoine Gallix

Reputation: 816

Set custom basic shortcut in a Bash shell

I'm currently trying to optimize or learn the keybindings of the applications I use the most, in a simple and ergonomic way. Inspired by Ergoemacs keybindings, I would like to rebind some very basics commands for use in Bash as for example:

I've seen ways to bind custom complex commands. I've found nowhere how to do this. In windows I used to do it system wide with autohotkeys but I'm now with a linux system and no autohotkey alternative works well for me.

How can I set those key bindings for my Bash terminal?

Upvotes: 5

Views: 6609

Answers (1)

plesiv
plesiv

Reputation: 7028

Bash key-bindings configuration

  • For all above combinations, except the last one Ctrl+c/x/v...

You are looking for readline (documentation) library settings. In Linux, programs that offer some kind of command line interface (e.g. bash interactive shell, octave interactive shell, python interactive shell etc.) use readline library to customize key-bindings.

Key-bindings are usually added in .inputrc configuration file in user's home directory. Here is an example of .inputrc configuration file.

Terminal emulator (e.g. gnome-terminal) key-bindings configuration

  • For the last one Ctrl+c/x/v...

In menubar of terminal emulator: Edit > Keyboard shortcuts.

Upvotes: 6

Related Questions