I was wondering if there is a way to get which window number of screen that is active? As in: screen -X get-window-number I have found no way to list screen windows to output, only the actual screens.

The reason I would like to do this is because I use screen quite a lot and it would be nice to always see the screen number I'm currently at. I planned to incorporate that into the bash PS1 so it would come to look something like: [16:00:00][0]admin@Server:/etc$ so it would be [time][window number]username@hostname:pwd$

Does anyone have a way of doing that?

  • Have you considered enabling the status line? – chepner Sep 20 '13 at 14:11

You can use $WINDOW variable which is set to the window number of a screen window at creation time. It's as easy as

echo $WINDOW
|improve this answer|||||

Your Answer

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

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