Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tmux over ssh #3541

Closed
leier69 opened this issue Apr 27, 2021 · 41 comments
Closed

tmux over ssh #3541

leier69 opened this issue Apr 27, 2021 · 41 comments
Labels

Comments

@leier69
Copy link

leier69 commented Apr 27, 2021

OS: Arch Linux (btw)
Bug is on x11 and wayland.
Bug is not present using alacritty, or gnome terminal.

Bug:

I ssh and tmux works as expected on my server, but when I try to do control shortcusts in tmux or bash it does not work and prints random characters. Example bellow.

[2000][leier@serverhost][] /home/leier$ 7;5uc7;5uc7;5u9;5u9;5u9;5u9;5u9;5u7;5uc8;5u8;5u8;5u8;5u
-bash: 7: command not found
-bash: 5uc7: command not found
-bash: 5uc7: command not found
-bash: 5u9: command not found
-bash: 5u9: command not found
-bash: 5u9: command not found
-bash: 5u9: command not found
-bash: 5u9: command not found
-bash: 5u7: command not found
-bash: 5uc8: command not found
-bash: 5u8: command not found
-bash: 5u8: command not found
-bash: 5u8: command not found
-bash: 5u: command not found
[2001][leier@serverhost][] /home/leier$ 
❯ kitty --debug-config 
kitty 0.20.1 created by Kovid Goyal
Linux arch 5.11.16-arch1-1 #1 SMP PREEMPT Wed, 21 Apr 2021 17:22:13 +0000 x86_64
Arch Linux \r (\l)
LSB_VERSION=1.4
DISTRIB_ID=Arch
DISTRIB_RELEASE=rolling
DISTRIB_DESCRIPTION="Arch Linux"
Loaded config files: /home/leier/.config/kitty/kitty.conf
Running under: X11

Config options different from defaults:
background            Color(red=10, green=15, blue=20)
bold_font             Hack Bold
bold_italic_font      Hack Bold Italic
draw_minimal_borders  False
font_family           Hack
font_size             13.0
initial_window_height (650, 'px')
initial_window_width  (900, 'px')
italic_font           Hack Italic
linux_display_server  x11
remember_window_size  False
term                  xterm-256color
window_border_width   (0, 'pt')
Added shortcuts:
	ctrl++ KeyAction(func='change_font_size', args=(True, '+', 2.0))
	ctrl+- KeyAction(func='change_font_size', args=(True, '-', 2.0))
@leier69 leier69 added the bug label Apr 27, 2021
@leier69
Copy link
Author

leier69 commented Apr 27, 2021

For specificity: It happens when I try to do any ctrl+anything shortcut. both bash and tmux shortcuts.

And I'm pretty sure this did not happen in past kitty versions. I moved to alacritty and is now moving back to kitty.

@kovidgoyal
Copy link
Owner

See https://sw.kovidgoyal.net/kitty/faq.html#i-am-using-tmux-and-have-a-problem

And I can tell you that doing ssh and then running tmux and pressing
either ctrl+c or ctrl+d works as expected on my arch system.

@leier69
Copy link
Author

leier69 commented Apr 27, 2021

@kovidgoyal I love that its you maintaining kitty. Your so awesome man. Thanks for quick answer!

@kovidgoyal
Copy link
Owner

You're welcome :)

@leier69
Copy link
Author

leier69 commented Apr 27, 2021

Wait... That did not answer me tho. I really need tmux over ssh for my work. I tried reading up on doc and various issues, but the issue still remain ☹️ Is there any work around? @kovidgoyal

@Luflosi
Copy link
Contributor

Luflosi commented Apr 27, 2021

See what echo $TERM prints inside and outside of tmux.

@leier69
Copy link
Author

leier69 commented Apr 27, 2021

outside tmux or ssh:

❯ echo $TERM    
xterm-256color

when I ssh to server:

[2002][leier@server][] /home/leier$ echo $TERM
xterm-256color

when I tmux:

[2004][leier@server][] /home/leier$ echo $TERM
screen

@Luflosi
Copy link
Contributor

Luflosi commented Apr 27, 2021

Set it to xterm-kitty outside of tmux.

@leier69
Copy link
Author

leier69 commented Apr 27, 2021

I get this when I ssh into the server then @Luflosi

tput: unknown terminal "xterm-kitty"

and no colors

@leier69
Copy link
Author

leier69 commented Apr 27, 2021

Then when trying to start tmux, I get this:

open terminal failed: missing or unsuitable terminal: xterm-kitty

@Luflosi
Copy link
Contributor

Luflosi commented Apr 27, 2021

Does tmux print this error? Does infocmp xterm-kitty print something on the server?

@leier69
Copy link
Author

leier69 commented Apr 27, 2021

infocmp xterm-kitty shows the same on the remote host inside and outside tmux after using kitty +kitten ssh myserver.

That fixed the color issue. But ctrl+l or any tmux command still does not work. @Luflosi. And I appriciate you taking out time to help the ones with special needs

@Luflosi
Copy link
Contributor

Luflosi commented Apr 27, 2021

Is TERM set to xterm-kitty on your local machine, outside of SSH?

@kovidgoyal
Copy link
Owner

What ctrl keys are you pressing?

@leier69
Copy link
Author

leier69 commented Apr 27, 2021

local machine or plain kitty:

❯ echo $TERMINFO $TERM
/usr/lib/kitty/terminfo xterm-kitty

Inside ssh without tmux:

[2002][leier@server][] /home/leier$ echo $TERMINFO $TERM
xterm-kitty

Inside ssh with tmux:

[2002][leier@server][] /home/leier$ echo $TERMINFO $TERM
screen

@leier69
Copy link
Author

leier69 commented Apr 27, 2021

@koekeishiya Im pressing forexample ctrl+l to clear the terminal, or ctrl+a AKA my tmux modifier.

@kovidgoyal
Copy link
Owner

And this happens only inside tmux, not if you just ssh and press those
keys?

@leier69
Copy link
Author

leier69 commented Apr 27, 2021

yea :(

@leier69
Copy link
Author

leier69 commented Apr 27, 2021

[2000][leier@serverhost][] /home/leier$ 7;5uc7;5uc7;5u9;5u9;5u9;5u9;5u9;5u7;5uc8;5u8;5u8;5u8;5u
-bash: 7: command not found
-bash: 5uc7: command not found
-bash: 5uc7: command not found
-bash: 5u9: command not found
-bash: 5u9: command not found
-bash: 5u9: command not found
-bash: 5u9: command not found
-bash: 5u9: command not found
-bash: 5u7: command not found
-bash: 5uc8: command not found
-bash: 5u8: command not found
-bash: 5u8: command not found
-bash: 5u8: command not found
-bash: 5u: command not found
[2001][leier@serverhost][] /home/leier$

@kovidgoyal
Copy link
Owner

Then its likely something in your tmux config, bisect it to find the
culprit.

@crepppy
Copy link

crepppy commented Apr 28, 2021

I am also getting this issue, only started happening after updating kitty recently, not sure which commit caused the error

I am also unable to press enter

@trygveaa
Copy link
Sponsor Contributor

@leier69, @crepppy: Have you tried removing your tmux and shell config? It sounds like you have something enabling the new keyboard protocol introduced in version 0.20.0.

@nerdrew
Copy link
Contributor

nerdrew commented Apr 29, 2021

I also started seeing this with the recent kitty update (0.20.0). No control keys work for me (e.g. C-c, C-z).

@nerdrew
Copy link
Contributor

nerdrew commented Apr 29, 2021

I'm not sure if showkey is the right way to show this, but here's the showkey output for C-c:

outside tmux:

> showkey -a

Press any keys - Ctrl-D will terminate this program

^C 	 3 0003 0x03

inside tmux:

> showkey -a

Press any keys - Ctrl-D will terminate this program

^[[99;5u         27 0033 0x1b
         91 0133 0x5b
         57 0071 0x39
         57 0071 0x39
         59 0073 0x3b
         53 0065 0x35
        117 0165 0x75

@trygveaa
Copy link
Sponsor Contributor

@nerdrew: Please read my comment and try that:

Have you tried removing your tmux and shell config? It sounds like you have something enabling the new keyboard protocol introduced in version 0.20.0.

Your showkey output does indeed confirm that the new keyboard protocol is enabled inside tmux for you.

@nerdrew
Copy link
Contributor

nerdrew commented Apr 29, 2021

Looking now. FWIW, I don't have a shell or tmux config for my user. Do you know how to only use default configs for tmux?

@nerdrew
Copy link
Contributor

nerdrew commented Apr 29, 2021

What would enable the new keyboard protocol? That might be easier for me to search for in the running config :)

@nerdrew
Copy link
Contributor

nerdrew commented Apr 29, 2021

From what I can tell, this happens with the default settings for my tmux (version 1.8). I.e. there is no ~/tmux.conf , /etc/tmux.conf and it still happens when I start bash with sh or bash --noprofile --norc

@trygveaa
Copy link
Sponsor Contributor

Hm, okay. It does not happen for me with tmux 3.1c or 3.2. Version 1.8 is very old (8 years), so you should probably try upgrading it.

You can provide an empty config for tmux with the -f option, though if tmux is already running you have to use -L or -S so it doesn't connect to the existing session and uses that config. E.g.

tmux -f /dev/null -L tmux-test

You can see how the protocol is enabled in the docs i linked:

Emit the escape code CSI > 1 u at application startup or when entering alternate screen mode

So e.g. printf '\e[>1u', though it doesn't have to be enabled with this exact command of course.

@nerdrew
Copy link
Contributor

nerdrew commented Apr 29, 2021

Upgrade: LOL. I wish. Appears to still be broken when starting tmux with tmux -f /dev/null new-session sh

@trygveaa
Copy link
Sponsor Contributor

Do you have tmux running? As I said, you have to use -L or -S, otherwise it will use the same config as the running tmux (even if you use new-session).

@nerdrew
Copy link
Contributor

nerdrew commented Apr 29, 2021

no, tmux is not running

@kovidgoyal
Copy link
Owner

You need to ask the tmux developers why your version of tmux is doing that. And you can turn off extended keyboard mode with printf '\e[<u'

@nerdrew
Copy link
Contributor

nerdrew commented Apr 30, 2021

Interesting. printf '\e[>1u' doesn't fix it.

@nerdrew
Copy link
Contributor

nerdrew commented Apr 30, 2021

If I start screen and then start tmux, everything works...

@nerdrew
Copy link
Contributor

nerdrew commented Apr 30, 2021

Derp. I mean printf '\e[<u' doesn't fix it.

@kovidgoyal
Copy link
Owner

Try doing it multiple times since its a stack.

@nerdrew
Copy link
Contributor

nerdrew commented Apr 30, 2021

LOL. I needed to do printf "\033Ptmux;\033\033[<u\033\\" to get it past the tmux filtering of unknown escape codes...

@nerdrew
Copy link
Contributor

nerdrew commented Apr 30, 2021

Thanks!

@benoitjpnet
Copy link

LOL. I needed to do printf "\033Ptmux;\033\033[<u\033\\" to get it past the tmux filtering of unknown escape codes...

I have the same bug... And this resolve it.
This is a regression as previous version of Kitty were working fine. Seems not backward compatible!

cspeterson added a commit to cspeterson/dotfiles that referenced this issue Nov 14, 2022
…ovidgoyal/kitty#3541"

This reverts commit 8f283b1.

It didn't work for subsequent connections - I'll just get a newer Tmux
compiled where needed ¯\_(ツ)_/¯
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants