Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The .screenrc file allows the user to specify that they want multiple windows open when screen is first run. Eg.

screen -t myWindowA 0 "" 
screen -t myWindowB 1 "-${SHELL}" 
screen -t myWindowC 2 "-${SHELL}"

What I would like is for each window to run some commands first, like:

screen -t myWindowA 0 "<go to directory a, source" 
screen -t myWindowB 1 "-${SHELL} <go to directory b, source>" 
screen -t myWindowC 2 "-${SHELL} <go to directoy c; start a watch on `ls -l`>"

Is there any way to do that?

Note this is similar to, but different from this issue.

share|improve this question
It's a tiny bit off topic, but have you heard of byobu? It's screen, but a bit easier to use. If so, nevermind. :) If not: – Stefano Palazzo Nov 8 '10 at 16:03
up vote 3 down vote accepted

Sure you can. On my servers i have a /etc/screenrc with:

screen -t TOP 0 top
screen -t ETC 1 cd /etc
screen -t Console 2
share|improve this answer
the first example works great, but I can't seem to get it to work with sourced environments, eg "source". I get "Cannot exec 'source': No such file or directory" then "[screen is terminating]". When I try to "cd" as in your second example, I get the a similar error. – Robert Gowland Nov 8 '10 at 19:58
@Robert Gowland source is a bash builtin, so it can't be executed by scree... Your best option, IMHO, is to create some bash scripts and execute them instead. – Mr Shunz Nov 9 '10 at 10:37
cool. Thanks for helping me understand what will and won't work. – Robert Gowland Nov 9 '10 at 14:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.