Showing GNU screen session name and window title in shell prompt

Screen supplies some environment variables (from screen(1) manpage):

STY              Alternate socket name.
WINDOW           Window number of a window (at creation time).

The "at creation time" means that if you renumber a window (using screen's number command), the shell will not be told about the change and $WINDOW will still be the same as the first window number.

You could use something like:

PS1='\u@\h(${STY}:${WINDOW}):\w$ '

I always use precise screen session names. Then I can add screen's STY env var, with the numeric id stripped out (thanks dimo414), to PS1. I don't decorate it with curly braces or anything because I'm not always in a session. Simple example:

PS1='\u@\h ${STY#[0-9]*.} \w$ '