4

I'm wondering if there is some way to create a heirarchy/tree of terminals in a screen session on Linux?

I don't mind hacking on this, so if there is a project out there that's working on this, I'd like to get involved with it.


Explanation:

I'd like to have something like

1 bash
  1.1 bash
  1.2 bash 2 bash 3 bash
  3.1 bash
    3.1.1 bash
    3.1.2 bash

It would be good if the terminals could be labelled instead of having to be navigated to via some arrangement that I suspect doesn't exist. So then you could jump to one using eg ^A:goto happydays or ^A:goto dykstra.angry.

Every browser offers the ability to create a flat set of tabs containing documents of an identical nature. GNU-screen implements the same functionality without using tabs. Linux and OS/X window managers provide the ability to organize windows into an array of workspaces, which amounts to again, the same deal.

I'd like to be able to not only group things into a tree structure, but also to create references (aka symbolic links, aka pointers) from one part of the structure to another, as well as apply properties (eg default directory, colorscheme, ...) recursively downward from a given node.

Tamara Wijsman
  • 57,083
  • 27
  • 185
  • 256
intuited
  • 3,291
  • 7
  • 30
  • 40
  • 1
    ....wow. where to start? oh yeah. Super User is not a discussion forum. don't get me wrong, this rant is the start of a fascinating discussion, but this isn't the place for it. – quack quixote Jun 21 '10 at 07:12
  • Indeed. I agree with what you're saying, but this could do with a `tl;dr` version that asks a specific question. – Phoshi Jun 21 '10 at 07:52
  • @quack quixote: Agreed.. I was definitely on a rant, and perhaps some other stuff, when I wrote that. I've added a synopsis in the form of a question. – intuited Jun 21 '10 at 17:33
  • 1
    @intuited: ok, i like the tl;dr summary, reopening. but c'mon, you could trim that rant down to two paragraphs and (a) still get the point across and (b) not need the giant `` tags. or better yet move the rant whole-hog to a blogpost somewhere, leave the tl;dr, two background paragraphs that aren't rant-y, and a link to the blogpost for more background. – quack quixote Jun 21 '10 at 17:41
  • Pfff what a mess... Hope this is more readable! Yet @quack is right: this isn't a discussion forum, so unless anyone can point you to something you're out of luck. – Ivo Flipse Jun 22 '10 at 07:09
  • @ivo: nice edit. @intuited: i know the edit cut out a lot that you might consider important; if you add stuff back, aim for conciseness and brevity. – quack quixote Jun 22 '10 at 07:31

3 Answers3

1

Yanno, that sounds a lot like what Byobu can do

Journeyman Geek
  • 127,463
  • 52
  • 260
  • 430
  • Really? can you elaborate? I read through the manpage and [a tutorial](http://lcorg.blogspot.com/2010/03/byobu.html). I learned that byobu can make it convenient to re-title a window, and can set up default windows for a session. But I'm really hoping for a way to set up a tree of windows, which can then be navigated with keymappings relevant to their perceived position within the tree structure. Did I miss that? – intuited Apr 18 '10 at 05:38
  • 1
    @intuited: you could get a "tree" effect in Byobu (or any Screen-based thing) by using multiple nested sessions. you could open a session with some set {A} of windows, then detach and open another session with another set {B} of windows, etc. then open yet another session, in window 1 reattach to {A}, in window 2 reattach to {B}, etc. add a tabbed terminal like gnome-terminal and open one of those "master sessions" in various tabs, and you've got a tree of sessions. (have fun with escape chars tho.) – quack quixote Jun 21 '10 at 18:04
  • @quack: I've dabbled in that, and it's sometimes useful. One thing that's important is that there be some way to move things around in the heirarchy. I guess if I created a screen *session* in every screen, rather than just opening the window, I could detach it and move it to another location in the tree. – intuited Jun 23 '10 at 00:51
  • Actually if it's possible to tell screen to pass through ^A-a's when it only has one window open, that could work pretty well... ie the ^A-a would be relayed up to the parent screen session, unless this screen session has already been split into two child sessions. I think there are some trickinesses to work out, but it seems at least vaguely promising. – intuited Jun 23 '10 at 00:56
  • i have read somewhere that moving windows between sessions is already on the screen development "wishlist". and as far as passing escapes, i'm pretty sure the outer session gets it first. i'd expect that *would be* the "parent session", but it may depend on how exactly things are attached. (if i open session {A}, {B}, and {C} in the background, i could attach 3 windows of {D} to them, but i could also attach {D} to windows {A:2}, {B:7}, and {C:3}. now which one's the "parent"? :) @intuited – quack quixote Jun 23 '10 at 01:02
  • @quack: Yeah, passing escapes is not so bad, it works like this: if you've got a screen within a screen, to switch to the previous window in that inner session you do ^a-a-^a-a. It sort of screws the convenience factor, but it's not too hard to grok/remember. Oh crap, you're right, I got dyslexed when I was writing that last comment: you would just do ^a-a to switch to the other screen session. Anyway yeah I like the way that screen turns the computer into a polyphilic commune. – intuited Jun 24 '10 at 03:19
  • @quack: But it would be a lot easier to keep track of if there was just one commune instead of a bunch of interbreeding ones.. in other words if you could navigate within an interlinked heirarchy instead of having to somehow remember that you need to hit ^a-a-^a-a-^a-a-^a-a because you want to toggle from 1.2.1 to 1.2.2. or something like that. like if it worked like a directory structure (with symlinks) and you could do the equivalent of `cd ..` or `cd SOMESESSION`. maybe by actually typing that, via `^a-:`? and an "`ex`" mode to make it convenient to rearrange stuff? – intuited Jun 24 '10 at 03:25
1

just found this question.

You can do what I believe you are looking for right inside gnu-screen. In .screenrc, add:

screen -t 1.1 0 # just a shell

screen -t 1.2 1 screen -m -e^xx-c ${HOME}/.screenrc-1.2 #new session inside accessed by Ctrl-x

screen -t 1.3 2 screen -m -e '^xx' -c ${HOME}/.screenrc-1.3 #yet another new session

Then the ~/.screenrc-1.2 and ~/.screenrc-1.3 could be separate setups for the subsessions; for example, .screenrc-1.3 could define more subsessions. Once inside the entire session, you can switch between them, and the inner sessions have their own control sequences (ctrl-x), you can navigate to the by name or number: select 1.2.

Arcege
  • 2,103
  • 11
  • 15
  • At this point I'm fairly well adapted to using ^Aaa... to access screens within screens within... But it's good to know about the -t and option and `:select` command. – intuited Jan 30 '11 at 06:16
  • Main thing missing here is the ability to move a window from one `screen` session to another. – intuited Jan 30 '11 at 06:17
0

Nesting screen sessions (as suggested by Archege) will achieve what you're looking to do, but managing the multiple layers of nesting (especially when it comes to sending commands to the correct screen session) can be a pain. More recent versions of screen (I'm using 4.1.0) support window groups, which can do most of what you're looking to accomplish. Window groups don't seem to be capable of anything analogous to hardlinking, and the feature has only minimal integration and documentation (presumably due to being comparatively new and relatively obscure). However, a notable advantage of window groups is that they work through a single screen session; consequently, managing the nested arrangement is less troublesome.

The code block below is a commented copy/paste of the sections of my .screenrc that are relevant to window groups:

# first, make a root group that all of the other groups will go into
# note that the "//group" is *NOT* a comment; without it, only a
#  standard window will be spawned
screen -t root    0 //group

# select the root window to make sure that the next created group will
#  end up there, and make another group nested inside of it
select 0
screen -t shells  1 //group

# rinse and repeat for more groups
select 0
screen -t editors 2 //group
select 0
screen -t SSH     3 //group
select 0
screen -t scratch 4 //group
select 0
screen -t scripts 5 //group

# to add windows into first group, select it and then create windows
#  as normal
select 1
screen 6
screen 7

# rinse and repeat as desired for the other groups
select 2
screen 8
# and so on...
redyoshi49q
  • 121
  • 1
  • 5