# Kak mode for the shell

**URL:** <https://discuss.kakoune.com/t/kak-mode-for-the-shell/1682>\
**Category:** Help\
**Tags:** terminal\
**Created:** [April 11, 2021, 6:40pm UTC](https://discuss.kakoune.com/t/kak-mode-for-the-shell/1682 "2021-04-11T18:40:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![abstractlyZach](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/abstractlyzach/32/738_2.png) [@abstractlyZach](https://discuss.kakoune.com/u/abstractlyZach)\
**Post date:** [April 11, 2021, 6:40pm UTC](https://discuss.kakoune.com/t/kak-mode-for-the-shell/1682/1 "2021-04-11T18:40:51Z")

</div>

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 😅.

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

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [April 11, 2021, 7:20pm UTC](https://discuss.kakoune.com/t/kak-mode-for-the-shell/1682/2 "2021-04-11T19:20:06Z")

</div>

I guess you have to dig into [GNU Readline docs](https://tiswww.cwru.edu/php/chet/readline/readline.html) or even the source code to see how `vi` mode is implemented there. Or maybe look for realine alternative, e.g. zsh uses [ZLE](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html), and maybe there the story of implementing custom editing modules is better.

---

<div class="post-metadata">

**Author:** ![Screwtapello](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/screwtapello/32/12_2.png) [@Screwtapello](https://discuss.kakoune.com/u/Screwtapello)\
**Post date:** [April 12, 2021, 12:30am UTC](https://discuss.kakoune.com/t/kak-mode-for-the-shell/1682/3 "2021-04-12T00:30:42Z")

</div>

I tried to write [a Kakoune mode for readline](https://github.com/mawww/kakoune/wiki/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.

---

<div class="post-metadata">

**Author:** ![enricozb](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/enricozb/32/808_2.png) [@enricozb](https://discuss.kakoune.com/u/enricozb)\
**Post date:** [April 19, 2021, 12:14am UTC](https://discuss.kakoune.com/t/kak-mode-for-the-shell/1682/4 "2021-04-19T00:14:21Z")

</div>

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](https://fishshell.com/docs/current/#shared-bindings), and after saving and quitting, the buffer contents will be on the shell line. It’s

---

<div class="post-metadata">

**Author:** ![enricozb](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/enricozb/32/808_2.png) [@enricozb](https://discuss.kakoune.com/u/enricozb)\
**Post date:** [April 19, 2021, 12:15am UTC](https://discuss.kakoune.com/t/kak-mode-for-the-shell/1682/5 "2021-04-19T00:15:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JacobTravers](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/jacobtravers/32/848_2.png) [@JacobTravers](https://discuss.kakoune.com/u/JacobTravers)\
**Post date:** [April 19, 2021, 8:27pm UTC](https://discuss.kakoune.com/t/kak-mode-for-the-shell/1682/6 "2021-04-19T20:27:56Z")

</div>

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](https://github.com/fish-shell/fish-shell/issues/7748)
