[vox-tech] starting screen from shell startup script
ME
vox-tech@lists.lugod.org
Wed, 21 May 2003 06:23:59 -0700 (PDT)
> So now I'm ready to learn screen. So I'm about to put screen in my
> startup script. Except...
>
> Once I login, it'll execute screen, which will run screen again, which
> will run screen again, then again, etc. and it'll be caught in an infinite
> loop. Or does it detect itself somehow? Or do I play with my
> bash_profile vs. bashrc thing? How do I prevent it from running itself
> recursively?
Use an enc var created by screen when it runs to tell your startup
scriptto act differently.
Two such env vars are useful with this
"WINDOW" and "TERM"
By default, screen sets your TERM to be "screen"
Alsl, for each virt screen (0-9) the env var "WINDOW" is given the
value associated with the screen you are on.
If you manually type "screen" and then manually type "control-a c" 3
times, you will be on "window" 3. Press "control-a 2" and you will be on
window 2. the env var WINDOW should have this.
Here is a sample condition check that can be addded to ~/.bashrc perhaps
within the section that is used for interactive sessions:
if [ "$TERM" != "screen" ]; then
screen
fi
You could of course look to see if WINDOW is greaterthan or equal to "0"
instead. You can also use conditionals to have screen automagically
startup applications in each window for you.
-ME