Implement tmux control mode (-CC) #5612
Labels
Issue-Feature
Complex enough to require an in depth planning process and actual budgeted, scheduled work.
Resolution-Duplicate
There's another issue on the tracker that's pretty much the same thing.
Description
Tmux/Screen has long been considered an essential tool when working in terminals on Linux, and a huge portion of all WSL users are likely using tmux.
With the introduction of panes in the latest release, it is now reasonable to consider integrating with tmux's control mode (tmux -CC). This is a textual interface provided by tmux specifically for the purpose of integrating with terminal emulators. The most prominent example of such integration is iTerm2.
This would build on the existing pane implementation to allow terminal windows displaying a tmux session to essentially function as a renderer of tmux's state in the following ways:
Panes created/destroyed in tmux would create/destroy corresponding panes in windows terminal, and vice versa.
Changes in size to panes in either tmux or windows terminal would be mirrored respectively.
Text selections within windows terminal would therefore be limited by the presence of native panes, and prevented from spanning multiple panes.
Window names would be updated based on the name for the active pane within a tmux session.
It may or may not be helpful to pass through raw keystrokes to tmux to allow them to be interpreted, and the output reinterpreted by the terminal emulator so that users can make use of existing tmux key bindings.
Doing this would allow for native-feeling experiences even for terminals over SSH; reduce configuration for tmux users; and gloss over some of the awkwardness of overlapping functionality. For example, a terminal emulator can't provide tmux's persistence functionality and therefore will never replace it, but the presence of panes within panes within panes (vim within tmux within a terminal emulator that has panes...) can get quite awkward and difficult to manage. It also reduces the experience of latency when working with tmux.
Implementation details
To spy on an tmux session's control codes, open a tmux session in one terminal window, and in another, attach to the same session with
tmux -CC attach
. You will now see the outputted control codes for every action within tmux in the original window, including the raw text output for each pane.From the man pages:
`
CONTROL MODE
`
In Summary
Windows Terminal should detect when tmux is launched in control mode (
tmux -CC
), and should start rendering the parsed output described above using native GUI panes. It would be reasonable to prevent non-tmux panes from being created in this mode, or otherwise create placeholder panes within the tmux session displaying some simple but useful representation of what is in the pane.When the window is closed, session is detached. Tmux is left running. This would also facilitate persistent layouts without the need to implement it natively.
The ability to create profiles which automatically attach to a tmux session would enhance the usefulness of this feature.
The text was updated successfully, but these errors were encountered: