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

Support tmux control mode #336

Open
3 of 9 tasks
wez opened this issue Nov 20, 2020 · 10 comments
Open
3 of 9 tasks

Support tmux control mode #336

wez opened this issue Nov 20, 2020 · 10 comments
Labels
enhancement New feature or request multiplexer

Comments

@wez
Copy link
Owner

wez commented Nov 20, 2020

tmux offers a control mode that allows a terminal emulator to issues commands and react to events happening in a tmux server through the terminal input/output streams.

This issue tracks adding support for this control mode such that it is treated as a multiplexer domain within wezterm, allowing wezterm to connect to a tmux instance and render native windows, tabs and panes for the "remote" tmux session(s).

The basics:

  • tmux -CC attach attaches a domain to the tmux server
  • query and parse the list of sessions, windows, panes
  • synthesize and update the corresponding wezterm windows, tabs, panes in the Mux (with stubs for the render related functions)
  • Deal with ESC k <title> ESC \\ title sequence
  • implement render related functions to get line data from scrollback
  • implement key event related functions in terms of sending keys to the appropriate pane
  • implement spawn/split functions in terms of tmux commands

For a well integrated feature:

  • decide what to do with the tmux -CC attach pane. iTerm2 "buries" the hosting session, rendering it invisible while the tmux stuff is active. Right now wezterm prints a banner that says how to exit the session and leaves it in place
  • Cook up config options ala unix_domains to specify favorite tmux sessions to attach to, optionally with an ssh bootstrap, so that it is simple to do something like wezterm connect tmux-on-my-remote-server to have it ssh in and reconnect the windows/tabs/panes in a single step
@wez wez added the enhancement New feature or request label Nov 20, 2020
@wez
Copy link
Owner Author

wez commented Nov 20, 2020

@bcully started work on this a while back, and since then wezterm has evolved splits/panes and changed some guts around. I have a local branch with some improved foundations for tmux as a domain, which I want to keep in master so that we can avoid bit rot and chip away at it more incrementally.

wez added a commit that referenced this issue Nov 20, 2020
This crate knows how to parse data returned from the `tmux -CC` protocol.

refs: #336
wez added a commit that referenced this issue Nov 20, 2020
This causes `tmux -CC attach` to enter control mode and patch
into the terminal, printing out parsed event messages.

refs: #336
wez added a commit that referenced this issue Nov 20, 2020
the renderable interface is getting in the way though...

refs: #336
wez added a commit that referenced this issue Nov 20, 2020
This makes it easier to overrride/overlay inside the mux when
indicating that we are in tmux mode.

refs: #336
wez added a commit that referenced this issue Nov 20, 2020
@wez wez added the multiplexer label Jul 3, 2021
wez added a commit that referenced this issue Jan 17, 2022
wez added a commit that referenced this issue Jan 17, 2022
This isn't really correct: if there are splits, this is most
likely going to do the wrong thing.

refs: #336
@joexue
Copy link

joexue commented Jun 24, 2022

still think this feature is very useful even we have Wezterm native multiplex. For example, we cannot install Wezterm on the server while tmux is already there.

@joexue
Copy link

joexue commented Aug 30, 2022

Someone created a same function in hyper, looking forward to this feature in wezterm

https://www.reddit.com/r/commandline/comments/q5mj11/htm_a_cross_platform_alternative_to_tmux_control/

HTM - A cross platform alternative to tmux control mode

Hey all! I'm the creator of Eternal Terminal ( www.eternalterminal.dev ), a replacement for ssh/mosh that survives network failures while still supporting port forwarding and native scrolling.

I'm looking for some folks to try out a new utility: Headless Terminal Multiplexer (HTM). If you have used the amazing tmux control mode (tmux -CC) with iTerm on OS/X, then you know how nice it is to have a tmux experience with native tabs and scrollbars. HTM brings this same experience to Linux and Windows (and OS/X), using the Hyper.js terminal program. It's been working reliably for me, but I haven't shared it with anyone else yet. Please try it out and give me feedback, thanks!

@stefandxm
Copy link

Any news about this?

@snaggen
Copy link

snaggen commented Apr 28, 2023

While the wezterm multiplexter looks really good, I'm never able to use it since I always work on customer servers where I'm not allowed to install software of my picking. However, they almost always have tmux installed, so having tmux support in wezterm would be really nice. So, I hope this is something that is still on the roadmap, since wezterm is a really nice terminal.

@alxzh
Copy link

alxzh commented Jul 11, 2023

Can we prioritize this? With Eternal Terminal + tmux-cc (with is very mature and works flawlessly with iTerm) wezterm doesn't need to invest into tls domain and other tmux-cc would work nicely.

@wez
Copy link
Owner Author

wez commented Jul 11, 2023

@alxzh who is we? Are you a company willing to sponsor people to do the work on this?

@alxzh
Copy link

alxzh commented Jul 11, 2023

Sorry for now being clear :) I'm an individual. But I can help with working on that code to try to get it to merge into the main.

@wez
Copy link
Owner Author

wez commented Jul 11, 2023

I consider this to be a fairly big chunk of work. There are pieces in the repo today, but I think the approach should be re-thought, perhaps in concert with thinking about the scrollback design in #1342 and that together with how the multiplexer client works to try to reduce some code duplication and make things easier overall.

I do welcome contributions from others here, but I want to be up front that it will be a big time commitment both for them and for me to review and shepherd the work. I'd like to avoid us both investing a lot time and only producing partial results as has happened so far; the contributions have all be valuable and helped to figure out what this feature kinda looks like, but we obviously haven't successfully completed it yet.

For me personally: I do not have a lot of time for this particular feature, and since I don't use tmux any more (I built wezterm to replace my usage of tmux and it has been successful at that), I don't have motivation to spend my spare time on this, but I could make time for it if my GH sponsorship goal (https://github.com/sponsors/wez) was closer to being realized.

@vzaliva
Copy link

vzaliva commented Apr 8, 2024

I am very interested in this feature. Currently, to the best of my knowledge, no Linux terminal supports this, and it is often asked for. (On MacOS, iTerm has it.) Unfortunately, the wezterm current solution does not work for me as I do not have privileges to install server-side support on many hosts I log into.

I understand how open-source works and how precious little time people could contribute. I appreciate all the other work and features and want to explain why this feature may be attractive to many users. Again, thanks for all your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request multiplexer
Projects
None yet
Development

No branches or pull requests

6 participants