Search code examples
linuxbashgnu-screen

Is there a way to code Ctrl+a :multiuser on when using screen?


I want to run a script that sets up a screen session and then automatically makes it into a multi-user and also adds one of the users on my system.

So far, I have a script that creates the screen session, but I have to manually make it into a multiuser session then also add the user.

As far as I have seen there is no actual coding to do this and the only way to do it is with the Ctrl+a command.

Does anyone know of a way that means the command can be done in a bash script?


Solution

  • You can automatically run custom commands from a configuration file - by default $HOME/.screenrc will be loaded, if it exists, so you can just do:

    echo "multiuser on" >> $HOME/.screenrc
    

    to make your default screen start with :multiuser on. If you want to have a separate config from the default, just save the config with an alternative filename, and start screen with the -c option, e.g.

    screen -c multiuser.conf