Multiple Screen Profiles
I use screen a lot at work, and I love it. It makes me feel somewhat like Rimmer when he’s doing the tests in Holoship.
I find it useful in two different scenarios:
- General development — having an emacs window, a python window and a bash window open at the same time is really handy, and I can flip between them like a ninja with C-A C-A.
- Running our development stack — Having a .screenrc with all the commands in to get a development stack up and running saves me time and means I don’t have to remember to start up every single process.
So I really wanted two .screenrc’s — one for general development, and one for running our development stack. I wrote this little bash script…
base="/home/$USER"
orig="$base/.screenrc"
#If no first arg, just run screen
if [ -z $1 ]
then
echo "No arguments found. Using last profile..."
screen
exit
fi
#List available profiles if first arg is list
if [ "$1" == "list" ]
then
echo "Available screen profiles..."
cd "$base"
options=`ls .screenrc.*`
for opt in $options
do
ext=`echo "$opt"|awk -F . '{print $NF}'`
if [ "${ext#${ext%?}}" != "~" ]
then
echo $ext
fi
done
exit
fi
#Try to get the profile. If not found, run with given args
use="$orig.$1"
if [ -e "$use" ]
then
echo "Using profile from $use..."
cp -f "$use" "$orig"
shift
screen "$@"
exit
else
echo "Profile not found at $use. Using last profile..."
screen "$@"
exit
fi
If you add this to your .bashrc:
alias screen="/path/to/above/script"
, you now have the capability to run multiple screen profiles at your will. For example, I have the following at ~/.screenrc.main:
startup_message off
vbell off
altscreen on
screen -t Emacs 0 emacs -nw
… and at ~/.screenrc.stack:
startup_message off
vbell off
altscreen on
screen -t Emacs 0 emacs -nw
screen -t Python 1 python
screen -t Bash 2 bash
Then I can do the following…
Runs screen with the ~/.screenrc.main profile.
screen main
Runs screen with the ~/.screenrc.stack profile.
screen stack
Runs screen with the last used profile, with the -U option enabled
screen -U
You can pass args as normal, as long as the profile is the first argument
screen main -U
Lists your available profiles and exits.
screen list

Comments
Subscribe Make commentOk, I agree — it’s nice and all that, Screen is 1337 and any uber-hacker should use it. But then — nowadays we have quite big resolutions, and by using stuff like AwesomeWm (*nix) or SizeUp on Mac you have few windows opened and “switching”to other window takes like blink of an eye. Virtual desktops FTW :-) and btw — Screen was good 10 years ago ;-)
AwesomeWm looks pretty cool, I might check that out.
I think I may be about 10 years behind computing in general. Maybe in 10 years time I’ll start using Ruby on Rails or something equally as hip.
What I like about screen is that I can have a bazillion windows open, and my window manager doesn’t keep reminding me of the fact (for example by having loads of things in the task bar). This makes me less stressed as it feels like I have less to worry about.
BTW — We need to have a beer soon :)
RubyOnRails isn’t any different from lets say Cake or Django (or should it be the other way around?) — RoR was hip when it was released.
I recommend Awesome — it really speeds up your workflow + you don’t have to twist your fingers so much (I think you get enough of that from Emacs ;-))
Beer? Soon, really soon… :-)