I'm using screen after I have logged in with ssh to my server. As of now I set up the splits in my screen window by hand and run the commands by hand as shown in the following screen-shot:

enter image description here

  • The top part should run tail -n 1 -f /home/server/log/access.log.
  • The lower right part should run htop
  • The lower left one should simply be a command prompt

Is there any way to have that be done via commands/script, so I not have to redo it every time by hand?


2 Answers 2


For the specific case of window arrangements, there's a screen command to save them to a file: layout dump. From man screen:

layout dump [filename]

Write to a file the order of splits made in the current layout. This is
useful to recreate the order of  your  regions  used  in  your  current
layout.  Only  the  current  layout is recorded. While the order of the
regions are recorded, the sizes of  those  regions  and  which  windows
correspond  to  which regions are not. If no filename is specified, the
default is layout-dump, saved in the directory that the screen  process
was  started in. If the file already exists, layout dump will append to
that file. As an example:

           C-a : layout dump /home/user/.screenrc

will save or append the layout to the user's .screenrc file.

So, once you make the arrangement manually, press Ctrla:, then type layout dump /path/to/some/file. The layout will be saved to /path/to/some/file and you can then restore it in a new session with:

screen -c /path/to/some/file
  • +1 nice one; The split -v seems undocumented :) this is why I was struggling.
    – Videonauth
    Nov 28, 2017 at 1:55
  • @Videonauth it actually is documented under default keybindings section. C-a | (split -v) Split the current region vertically into two new ones. Nov 28, 2017 at 2:01
  • Yes, it looks it's only mentioned in the manpage, next to C-a |, but not in the GNU docs
    – muru
    Nov 28, 2017 at 2:01
  • 1
    Found an odd behavior you might want to mention: If you type for example layout dump ~/layout the process will fail, it need to full path (i.e. /home/$USER/layout)
    – Videonauth
    Nov 28, 2017 at 9:37
  • @Videonauth since tilde expansion is usually done by the shell, it's not surprising if a given command doesn't support it internally. Some do, most don't.
    – muru
    Nov 28, 2017 at 9:39

I came up with the following to create the output shown in my question and following @muru's excellent answer. Using layout dump gave me the following:

split -v

Note: Tilde (~) expansion does not work with layout dump so instead of ~/layout.dmp for example you would need to use /home/<username>/layout.dmp.

From which I then created the following .screenrc

# create the top screen
chdir /home/server/log
screen -t "Apache Log" tail -n 1 -f access.log
# split the screen and focus onto the new created space
#create the bash
chdir /home/server/log
# split vertically and focus onto the new area
split -v
# create the htop screen
screen -t "Htop" htop
# focus twice to end up with the bash area active

Now I only need to type screen and get my wanted layout started. I leave that here as an example for those who are wondering, but don't forget to up-vote @muru's answer, since he is the one who made me able to solve this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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