<S-CR> and other CSI u in CLI Coding Agent with tmux enabled #295
S1M0N38
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I had the problem that the pi coding agent support CSI u for parsing keymaps (e.g.
<S-CR>for new lines,<M-CR>for follow up message, ...) but using the default sidekick with tmux enabled in mux config was not working correctly.Trying to debug issues about escape sequence transmission between Terminal (Wezterm in my case), Tmux (multiplexer outside), Neovim, Neovim terminal buffer, tmux (inside neovim terminal buffer) and pi (the coding agent) can be a bit hard.
The following is my config collection that I've tested in these two cases
wezterm -> neovim -> sidekick.nvim + tmuxwezterm -> tmux -> neovim -> sidekick.nvim + tmuxTerminal Emulator
The first thing to configure is the terminal emulator (Wezterm in my case)
~/.config/wezterm/wezterm.luaThis configure the $TERM env var to be
wezterm(so other CLI/TUI apps knows about the terminal emulator capabilities) and enable kitty keyboard (which enable support for CSI u in wezterm, for example when you sendCtrl + Enterthe escape sequence\x1b[13;5uis sent).We also need to make our system aware which are the wezterm capability:
curl -o wezterm.terminfo https://raw.githubusercontent.com/wez/wezterm/main/termwiz/data/wezterm.terminfotic -x wezterm.terminfoinfocmp weztermTesting
You can test that you have setup your terminal emulator for CSI u by opening a empty Neovim terminal buffer and type in INSERT mode
Ctrl Vfollowed by a key combo. UsingCrtl Vin INSERT mode, enter a special insert mode where the key combo are translated in neovim format. For example you should see:Crtl + Enter-><C-CR>Alt + Enter-><M-CR>Alt + Ctrl + Shift + Enter-><M-C-S-CR>(
Mis for meta,Cis for control,Sis for shift,CRis for Carriage Return aka Enter, ...)Tmux
Then we need to configure tmux. It's important to be on version 3.6a or above (see by running
tmux -V) because there are some issue related to CSI u in version 3.5 and below. So update it if you need it.Sidekick.nvim
Now it's time to configure sidekick.nvim. I think that there is a issue about the implementation of the neovim terminal buffer (i.e. where the sidekick agent is run) which does not support fully the CSI u. So the transmission of keycombo (e.g. Shift-CR) is not perform in the right way and the coding agent does not recive the right escaping seq to perform the expected action (e.g. adding a new line in the prompt).
The following workaround in the sidekick.nvim should fix this by sending the full CSI u instead of the one automatically generated
Here I've defined two keymaps that maps the
Shift + EnterandAlt + Enterto the corresponding CSI u escape sequence (which the rest of the config is based on). You can define other keys as well.Beta Was this translation helpful? Give feedback.
All reactions