by oandrew · 5y ago · 0 comments
I really prefer screen's functionality, instead. Each pane can be independently switched to any of the pool of underlying ptys being managed. The exact layout of panes is more of an ephemeral thing. On wide terminals I can split side-by-side, on narrow ones I can split top-above-bottom (and these can even be different for different clients connected to the server). It handles the multiple attached clients by only make
I think tmux's model is due to being too closely modeled on GUI virtual desktops.
That rant aside, tmux does have some nice features available by default that take a fair bit of configuration to get working well in screen.
I actually did try to get the behavior I wanted out of nested tmux invocations and a hairy mess of scripts. There was no 'next-session' command (though now it looks like 'switch-client -l/-n/-p' would work. Hmm.)
I couldn't get it to work right, only a half-done approximation, and it involved way too many tmux interpositions.
Screen: client -> per client view of P panes -> P of entire pool of T terminals in session.
Tmux: client -> 1 of S sessions -> 1 of W windows -> P panes
To get splitting at the top level I need one top-level tmux client and its associated top-level session managed by one server. It can actually be locked to one window for what I care about.
In each of its panes, I need to run another tmux client so as to be able to actually change what final pty each pane will display. And each of these need to be separate sessions, so that I can display separate things in each of them. Each of these separate sessions will generally only have one window, with its implicit single pane. I should, of course, run all of these inner tmux sessions as a separate server from the top one.
Now I just have to make restricted keybindings for both the top and inner clients, and make make sure that any binding for the inner clients are replicated as "self-insert" in the top-level client. And remember that there are multiple places I can direct the command-lines (so need two bindings).
This results in the top level server having: client -> session -> 1 window -> P Panes -> P clients
And the bottom server having: P clients -> T sessions -> T windows -> T panes
And this doesn't yet let you have multiple top-level clients attached the way screen does.
I'm sure I could eventually sand off all the sharp edges where it doesn't do what I want and make this work.
Or I could just use screen.
if what matters is that different clients can look at different windows, then using multiple sessions with one window each will get you exactly that.
you may of course need to get used to tmux way of switching sessions (which is not different than tmux way of switching windows). however, i just checked, there is a command to switch to the next session, and you can bind that to a key. add another keybinding to create a new session, and that should get you to about 90% of your expected behaviour without nesting tmux.
Yes, using a terminal emulator that natively support tmux control mode (like iTerm2) is really nice because you can easily resize/rearrange the windows and panes via GUI actions, but absolutely suck when you have to reattach using a traditional terminal emulator because you now have to adjust all those windows and panes with keyboard actions.
You generally just need to do:
set -g mouse on
... by only making the ptys that are visible in multiple clients have the same size.
defscrollback 500000
scrollback 500000
termcapinfo xterm* ti@:te@
There you go, normal scrolling!https://github.com/mobile-shell/mosh/issues/122#issuecomment...
http://web.mit.edu/keithw/www/Winstein-Balakrishnan-Mosh.pdf (Section 6)
I'm pretty happy I got over that hurdle.
Adding byobu made it effectively impervious.
Story time: I had tmux sessions active on all our servers and would simply ssh into my work laptop from home, so the sessions were never really closed. One day, I decided to upgrade from 1404 to 1604 and closed out all my sessions (including on the servers because I was pushing out a new tmux config). After 5 minutes we started getting smss that the system was down and couldn't write to disk. One of our production servers had been set up with an encrypted home folder and when my session closed out, it closed the encrypted folder. Unfortunately, the ssh folder wasn't outside the encrypted portion, so we had to use IPMI to restore access. That's the story about how we started joking that closing my laptop is a great way to break the production system.
I also use it when I know I'll need to finish something on a different machine.
You're right about the keys if I'd be syncing them. But for my specific use case I happen to use passwords for these servers.