0

Is there a concise way to see which windows are attached in GNU screen?

I'm using screen to handle my terminals on a single session so I can easily switch between all open windows. Hence, I want my system to automatically re-attach to available windows. If none are available I want a new window to be created. My current setup (top of my .bashrc):

if [ "$TERM" != "screen" ]; then
    screen -r > /dev/null
    [ $? -eq 0 ] && exit
    screen -x -p + > /dev/null
    [ $? -eq 0 ] && exit
    exec screen
fi

This mostly does what I want - reattaches to an available session if possible with an existing window, and if already attached creates a new window. The problem it will create windows for an attached session whether available windows exist or not.

I am missing something to check for available windows for an already attached session to use with

screen -x -p <number>

Since I could not find screen solutions I looked for some in Bash, and here I am stuck on catching a window on detach, and writing the $WINDOW to a file.

I am open for other management solutions as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.