After so much time I made a Script to work around this completely missing feature.
First of all it needs a fifo:
mkdir ~/.screen
mkfifo ~/.screen/pipe
This named pipe is useful for the communication between the detatched session and the "Main-without-screen" session.
File sc ( in $PATH ):
#!/bin/bash
CONFIGFILE=~/.screen/"$1""rc"
if [ ! -r $CONFIGFILE ] ; then
echo "Configurazione per $1 Assente" >&2
exit 1
fi
exec 3<> ~/.screen/pipe
if [ "$STY" != "" ] ; then
screen -d "$STY"
echo "$1" >&3
else
screen -r "$1" 2>/dev/null || screen -S "$1" -c $CONFIGFILE
while true ; do
read line <&3
screen -r "$line" 2>/dev/null || screen -S "$line" -c ~/.screen/"$line""rc"
done
fi
An Example of a "CONFIGFILE" is:
~/.screen/Monitorrc
layout new Monitor
screen -t "bash" bash --login
split -v
focus next
split
focus bottom
screen -t "cv" sh -c "watch /usr/bin/cv -w"
split
focus bottom
screen -t "sys.log" sh -c "tail -F /var/log/sys.log"
focus up
focus up
resize 25
screen -t "top" sh -c "top"
focus left
The result is:
when you want to launch screen type:
sc Monitor
or another sessionrc you like to invent, I use the Session Work for various stuff
Ex: ~/.screen/Workrc
layout new Work
screen -t "bash" bash --login
Now we are in the Session Monitor, when we type:
sc Work
the session Monitor detaches itself and write "Work" to the namedpipe. Consequently the first sc script goes forward and attach the session "Work".
The sc invoked from the session Monitor close.
When we detach all Sessions we are in a infinite loop so we have to do Ctrl-c to exit.
You can set up much faster keybindings, like F11 for prev, F12 for next window. And change the screen escape character from
^a
to something else, so it's not ridiculously annoying to use emacs-style line editting in bash, anything else. I use^t
. – Peter Cordes – 2015-02-06T13:24:13.823