Kak mode for the shell

I like to use “vi mode” in my shell. You can activate it by using set -o vi in most shells. “vi mode” allows users to use vim commands to manipulate the shell, like jumping around text objects and scrolling through history with vim keys.

Now that I’m building a lot of muscle memory in Kakoune, I always find myself doing completely wrong things in my shell! I would love to have a “kakoune mode” for the shell so that I could unify my hotkeys and reduce the context-switching in my brain :sweat_smile:.

Questions:

  1. Is anyone aware of a “kakoune mode” for the shell?
  2. Would anyone be willing to build one if it doesn’t exist?
  3. Could anyone share resources to learn more about tackling a project like this? I have no idea where to start and this looks like it could be a fun side-project. For context, I use zsh and don’t plan on switching for the near future

I guess you have to dig into GNU Readline docs or even the source code to see how vi mode is implemented there. Or maybe look for realine alternative, e.g. zsh uses ZLE, and maybe there the story of implementing custom editing modules is better.

1 Like

I tried to write a Kakoune mode for readline and hence bash, python, psql, etc. but it doesn’t really work that well and I could never figure out why. If you’re using zsh, maybe zsh’s line-editing primitives will be more convenient for you.

1 Like

In my opinion nothing really replaces an actual kakoune instance. In fish, and I’m sure in other shells, alt+e will open up an instance of kakoune with the current shell command in a buffer, and after saving and quitting, the buffer contents will be on the shell line. It’s

1 Like

I didn’t even realize you could configure readline. I wonder if there’s a way to open the current line in a kakoune instance, instead of a kakoune mode.

I’ve actually opened up an issue for this in fish-shell. It’s basically an adjustment to the modal action and remapping fish_vi_keybindings. I just haven’t had the time to get it done: Feature Request: fish_kak_keybindings · Issue #7748 · fish-shell/fish-shell · GitHub