You are not logged in.
Pages: 1
Goal: trying to shortcut a lot of the routine stuff that I do with screen etc. Basically, when starting a new terminal, I want to start a screen session if there hasn't been one, if there is already screen sessions running, i want to reattach to detached ones first (the oldest first), if all of screens are already attached, then I would want to do nothing and just make the window a normal terminal.
Here's what I've came up with, it works, but it is certainly messy... I'm wondering if there's any other way to do it.
t=`pgrep '^screen'`
if [ $? -gt 0 ]; then
screen
else
screen -list | grep "(Detached)" -q
if [ $? -eq 0 ]; then
socket=`screen -list | sort -r | grep '(Detached)' -m 1 | cut -d '.' -f 1 | sed 's/\t//'`
screen -r $socket
fi
fi
Last edited by blu3ness (2008-04-11 01:05:23)
Archlinux on Compaq Presario v5000 laptop
Offline
Isn't 'screen -D -R' doing exactly that? ('man screen')
Offline
Not entirely true, I tried screen -D -R. For example, if I create a new bash session inside screen with ^a c, then the terminal would crash.
screen -D -R also allows for one terminal open at a time...
My idealized behavior would be when starting the terminal, if there's already a session attached, do nothing, if there's no screen sessions running, start one. If there's screen sessions detached, attach to the oldest session available.
Last edited by blu3ness (2008-04-10 23:31:36)
Archlinux on Compaq Presario v5000 laptop
Offline
Ah, it wasn't clear to me from the original post that you want to run this from .bashrc.
Offline
ya, apologies for being confusing...
Archlinux on Compaq Presario v5000 laptop
Offline
Pages: 1