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

Setting screen/tmux window name (ESC k) doesn't work with mosh #992

Open
mephinet opened this issue Aug 9, 2018 · 8 comments
Open

Setting screen/tmux window name (ESC k) doesn't work with mosh #992

mephinet opened this issue Aug 9, 2018 · 8 comments

Comments

@mephinet
Copy link

mephinet commented Aug 9, 2018

I'm trying to make mosh my primary terminal at $work, as I've been using it for months now and I'm pretty happy with it. One thing that strikes me, though, is that the window name setting does not work for me. My setup is this:
I use xfce4-terminal or xterm, and start tmux locally to have many panels (locally! - I am aware that some people run tmux on the remote end). tmux can be configured to display the session name or window name in the status bar. According to this man page the window name can be set with
$ printf '\033kWINDOW_NAME\033\\'.
When working locally or using ssh, this works. When using mosh, it doesn't, instead the string that should become the window name is echoed in the terminal.
My guess would be that mosh doesn't support the ESC k sequence, thus not forwarding it from the server to the client. In comparison, setting the window title with the OSC sequence ESC ] 2 ; works with mosh.
My environment: Gentoo Linux, tmux 2.6, mosh 1.3.2
FWIW, this was already discussed ~5 years ago: #477 (comment)

@mephinet
Copy link
Author

mephinet commented Aug 9, 2018

Taking a look at the code: https://github.com/mobile-shell/mosh/blob/master/src/terminal/terminalfunctions.cc#L606 is the code that makes the OSC sequence ESC ] 2 ; work - there is no equivalent for the ESC k sequence. If this analysis is correct, than setting the window name for tmux is a not-yet-implemented.

@cgull
Copy link
Member

cgull commented Aug 10, 2018

Correct, Mosh doesn't support this tmux-specific escape sequence. Unfortunately, it is not a standard ANSI control sequence, and it will not be ignored by terminals that don't support it. Mosh's virtual terminal aspires to emulate XTerm, and this doesn't fit very well with that, so I don't see implementing this any time soon.

@mephinet
Copy link
Author

Hi! I can understand that you're reluctant to implement non-standard extensions - the decision is of course up to you. Upon further reading (and trying to come up with a patch - WIP), I've realized that this feature is not tmux-specific, but was taken over from screen - as is documented here https://www.gnu.org/software/screen/manual/html_node/Control-Sequences.html and can be traced back in the code to at least 1991 (version 3.1). Maybe this sheds a more "standard" light on this sequence...

@mephinet mephinet changed the title Setting tmux' window name (ESC k) doesn't work with mosh Setting screen/tmux window name (ESC k) doesn't work with mosh Aug 10, 2018
@winny-
Copy link

winny- commented Aug 12, 2018

I use alacritty+tmux as my main terminal - so I also experience this issue. Perhaps we should look into implementing OSC sequence ESC ] 2 ; in tmux instead?

@mephinet
Copy link
Author

@winny- as documented in the man page, tmux distinguishes between names and titles (which always confuses me).

  • ESC ] 2 ; sets a pane's title (this uses an OSC and already works via mosh)
  • ESC k sets a window's name (this is screen-/tmux-specific and isn't supported by mosh yet)

@ryanerwin
Copy link

Would be awesome to see this feature get implemented in mosh, so that tmux is more consistent on ssh and mosh:

set-option -g set-titles on
set-option -g set-titles-string "#{host} - #{session_name}

For reference, here's the difference between the tmux titlebar in SSH and mosh.
image


Is @cgull saying the mosh team doesn't want to implement this?

Mosh's virtual terminal aspires to emulate XTerm, and this doesn't fit very well with that

If so, that would be kind of ironic since the mosh solution to no scrollback is tmux:

The workaround for now is to run "screen" or "tmux" on the remote end and use that for scrollback.

@ser
Copy link

ser commented Apr 3, 2020

it's really annoying, half of my tabs are polluted with [mosh] prefixes.

@normen
Copy link

normen commented Apr 23, 2020

Same is true for the MacOS terminal, I am trying to get the opened document in VIM displayed in the terminal top bar, it doesn't work when I work via MOSH, with SSH it works.

The sequence is ESC ] 6 ; <url of file> BEL or ^[]6;<url>^G for short.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants