I use GNU screen to keep a bunch of tabs open in my terminal session, and I would like to have a bash command,
watch -n 1 ps aux | grep something, that runs when I am looking at that screen tab, but stops running when I don't have any window displaying at the tab. Any ideas?
no can do. this cannot be automized. sorry.
workaround: use a command alias to start such a tab/window, eg "bind S screen ~/bin/myscript". put screen into zombie mode (eg with ":zombie z"). end the script when not required any more. switch to tab and restart process with ctrl-space.