I have a command I want to execute in .bashrc only when the current terminal
window is managed by GNU screen. How do I do this? Is there an environment variable for it? I used to have
if [ -n "$WINDOW" ]; then
command
fi
But from what I can tell, $WINDOW may or may not be defined across all screen
managed sessions.
Check for the environment variable $STY (contains info about the screen) or for $TERM being ‘screen’ (probably less reliable).