Essentially what it does is ensure that you only have one screen session at any given time. Any new programs are run as new windows inside your existing screen session. You can then scroll through your open screen apps with Ctrl+A N
I called this 'scn' but you could name it whatever you want. Just put it in your path and then alias all your apps you want to run in screen to 'scn command'.
For example I have this as ~/bin/scn which I added to my $PATH and I alias pork to 'scn pork' and irssi to 'scn irssi'. I also aliased sr='screen -r' for faster access.
Code: Select all
#!/bin/bash
if [ `screen -ls | wc -l` -gt 2 ];
then
echo "Screen found, running $@";
screen -X screen $@;
screen -r;
else
echo "No screen found. Creating one."
screen $@;
fi
Known issues:
- Running a command when an existing screen is found won't put that application in the foreground of your session.
- Running the same command over and over will just make more and more windows of that same command. Instead use screen -r to get to your previously started commands.


