joouha / euporie

Jupyter notebooks in the terminal
https://euporie.readthedocs.io
MIT License
1.54k stars 36 forks source link

Define Custom Keybindings #27

Closed sickerin closed 1 year ago

sickerin commented 1 year ago

Hi @joouha Is there a way to define custom keybindings? Most of the keybindings (Ctrl+N, etc) conflict with emacs keybindings/ terminals. So for the stuff that I rarely use, I'd probably turn them off.

Right now it's not possible to load some config right? I presume I need to change https://github.com/joouha/euporie/blob/main/euporie/key_binding/bindings/micro.py

Maybe having an easy method for editing custom keybindings could be an interesting addition. I might look into this.

joouha commented 1 year ago

Hi @sickerin,

This is not possible in v1.6.1, but it will be possible in v2.0.0 when it's released.

I've already implemented this in the dev branch if you want to check it out.

To configure the key-bindings in euporie-notebook, you'll need to add something like the following to $XDG_CONFIG_HOME/euporie/config.json:

{
  "notebook": {
    "key_bindings": {
      "euporie.notebook.app.NotebookApp": {
        "new-notebook": [],
        "quit": ["c-q", "c-p"],
      }
    },
  }
}

This will disable the Ctrl+N key-binding for the new-notebook command, and adds an additional key-binding Ctrl+P for the quit command.

A key-binding editor dialog would be a nice addition, as editing the config file is a bit fiddly.

joouha commented 1 year ago

I've released v2.0.0, which now supports custom key-bindings: https://euporie.readthedocs.io/en/latest/pages/keybindings.html#custom-key-bindings