Ubuntu – GNU screen: Running commands in different window when screen is started

gnu-screen

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.

Best Answer

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