2

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 a.sh" 
screen -t myWindowB 1 "-${SHELL} <go to directory b, source b.sh>" 
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.

  • 1
    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: https://help.ubuntu.com/10.04/serverguide/C/byobu.html – Stefano Palazzo Nov 08 '10 at 16:03

1 Answers1

3

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
  • the first example works great, but I can't seem to get it to work with sourced environments, eg "source env.sh". 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 08 '10 at 19:58
  • 1
    @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. – Daniele Santi Nov 09 '10 at 10:37
  • cool. Thanks for helping me understand what will and won't work. – Robert Gowland Nov 09 '10 at 14:13