Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
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 7: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 7: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 <rant></rant> 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 7:09
show 2 more comments

3 Answers

Yanno, that sounds a lot like what Byobu can do

share|improve this answer
    
Really? can you elaborate? I read through the manpage and a tutorial. 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 5: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 0: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 0: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 1:02
show 2 more comments

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.

share|improve this answer
    
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 6:16
    
Main thing missing here is the ability to move a window from one screen session to another. –  intuited Jan 30 '11 at 6:17
add comment

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...
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.