wezterm icon indicating copy to clipboard operation
wezterm copied to clipboard

Support tmux control mode

Open wez opened this issue 5 years ago • 10 comments

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:

  • [x] tmux -CC attach attaches a domain to the tmux server
  • [x] 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)
  • [x] 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 avatar Nov 20 '20 17:11 wez

@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 avatar Nov 20 '20 17:11 wez

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 avatar Jun 24 '22 15:06 joexue

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!

joexue avatar Aug 30 '22 15:08 joexue

Any news about this?

stefandxm avatar Oct 25 '22 00:10 stefandxm

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.

snaggen avatar Apr 28 '23 05:04 snaggen

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.

alxzh avatar Jul 11 '23 17:07 alxzh

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

wez avatar Jul 11 '23 18:07 wez

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.

alxzh avatar Jul 11 '23 18:07 alxzh

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 https://github.com/wez/wezterm/issues/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.

wez avatar Jul 11 '23 20:07 wez

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!

vzaliva avatar Apr 08 '24 20:04 vzaliva