3

Here's my problem :

I have a particular setup with screen that I like to launch on startup, to quickly have access to several programs I use often.

Here's an example :

screen -U -S test -t shell

Within this screen session :

screen -t irc (in which I'll launch irssi) screen -t process (in which I'll launch top) ...

Note that this result in having one unique sessions, and multiple shells in this session. I specify it, because so far, my tests have brought me to the point where my script creates a screen session, in a session, in a session ... and I can't really figure out why.

I'd like to know if it's possible to build up a script that I could launch to create the whole screen setup and start the programs automatically when executed.

Thanks for any advices. =)

kRYOoX
  • 147
  • 5

2 Answers2

1

You can use screen -S sessionname -X command to run tmux-commands1 in an existing session, e.g. -X screen top to create a new window and run top in it. Note that the newly created window will be closed when the command terminates. If you would like to have a shell afterwards, use something like -X screen sh -c 'ls; bash'.

There are also ways to run commands in existing screen windows, see these two questions:

1: You can find the complete list of tmux commands on its manpage.

n.st
  • 2,008
1

Create a ~/.screenrc file containing:

defutf8 on
sessionname test
screen -t shell   0
screen -t irc     1 irssi
screen -t process 2 top

Then, when you log in to the box, execute

screen -DR

which detaches any currently running screen and attaches to it, or if no screen is running it creates a new one.

glenn jackman
  • 27,524