On Fri, Jan 21, 2022 at 1:45 PM Eric House <eeho...@eehouse.org> wrote:
> > With screen you can resize the terminal size to fit using ctrl-a F - > > that's your screen's control command followed by a capital F. > > That works! If I have two different terminals ssh'd into the same screen > session and resize one then ctrl-A F it, the session in the other terminal > changes size to match. > > But: unlike with tmux (which is totally new to me as I said), the two > sessions are not kept in sync. > If I switch panes in one, or split the window, the other doesn't change. > Since one of my sessions will be invisible, I need it to automatically > follow whatever I do in the other so that keystrokes will always go where I > can see them. Is that possible with screen? Seems a useful feature e.g. for > demonstrating something remotely, but I can't find anything even asking how > to do it (so I'm probably asking the wrong question....) > tl;dr: don't split screens in multi-user sessions. Use a single window and a single region. Just a bit of nomenclature to make sure we are on the same page. There are four main objects with screen: a session, a window, a layout, and a region. By default a new screen "session" creates a new "window" and displays it in a single "region". But it can get more complex. A session can contain one or more windows and one or more regions. The arrangement of regions ( i.e. number, size, position ) is called a "layout". Regions can be blank or display a window. ( This description is simplified, but suffices. ) Here's a walk through to demonstrate. Type the following commands: screen -dmS foo # creates a screen session named "foo" screen -x foo # attaches to the screen session named "foo" At this point you'll have a single screen session named "foo", a single window running bash, and a single region displaying the window. Type the following commands. sleep 12345 # this is to keep track of what window we are in ^ac # create a new window running bash sleep 54321 # again, to keep track of what window we are in ^ac # create a new window running bash We now have three windows: one with a bash prompt and two running sleep for various times. Type this commands: ^a" # this will list the windows, press the up/down to move between windows, press enter to select That will allow you to switch between windows. Because we only have a single region, we can only view one window at a time. Type these command: ^a| # this will split the region in two with a new blank region on the right ^a{tab} # this will change focus to the new region; the {tab} is the tab key ^a" # this will list the windows, press the up/down to move between windows, press enter to select You now have two regions, side-by-side, each displaying one of the windows. In fact, you could have both regions displaying the same window. As mentioned before, the arrangement of regions is called a "layout". Type these command: ^ad # this will detach from the screen session screen -x foo # this will attach to screen session "foo" Notice that when you detach and then reattach, your layout is apparently lost and you have again a single region displaying one of the windows. Question: Of the three windows, which one will be displayed when you reattach? ( I don't know the answer to this, but the choice of window appears arbitrary. ) It appears that a second connection behaves the same: it starts with a single region displaying one of the windows. It knows nothing about existing regions, any layouts, or what window is in what region. Question: How do you get two connecting processes to have the same layout when connected to the same screen session? Saved layouts ... maybe. I'm not that familiar with working with layouts and haven't had much success with them. And I'm not encouraged from this in the "layout dump" command: "While the order of the regions are recorded, the sizes of those regions and which windows correspond to which regions are not." But maybe they'll work good enough. https://www.gnu.org/software/screen/manual/html_node/Layout.html Another possible solution would be to run screen within screen. That is, create two screen sessions, e.g. foo and bar. Have both users connect to session foo and then connect to session bar. This does have the desired effect of being able to create regions in session "bar" and have all regions displayed to both users. However, this gets really confusing really quickly, but might work for you. Admittedly, this post turned out longer than I had intended. But I hope that it clarifies how screen works, at least a little. Good luck and let us know how things work out. Regards, - Robert