Как запустить экран с несколькими разбиениями непосредственно из командной строки?

Я использую screen после входа в систему с ssh на моем сервере. На данный момент я настраиваю расколы в окне экрана вручную и запускаю команды вручную, как показано на следующем скриншоте:

Верхняя часть должна работать tail -n 1 -f /home/server/log/access.log. Нижняя правая часть должна работать htop. Нижняя левая строка должна просто быть командной строкой

. Есть ли способ сделать это с помощью команд / сценариев, поэтому мне не нужно каждый раз переделывать ее рука?

10
задан 28 November 2017 в 13:39

6 ответов

Для конкретного случая расположения окна есть команда экрана, чтобы сохранить их в файл: layout dump. Из 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.

Итак, как только вы сделаете компоновку вручную, нажмите Ctrla :, затем введите layout dump /path/to/some/file. Макет будет сохранен в /path/to/some/file, и вы сможете восстановить его в новом сеансе с помощью:

screen -c /path/to/some/file
14
ответ дан 22 May 2018 в 15:50
  • 1
    +1 хороший; [F1] кажется недокументированным :) вот почему я боролся. – Videonauth 28 November 2017 в 05:55
  • 2
    @Videonauth на самом деле документируется в разделе разделов ключевых слов по умолчанию. [F1] – Sergiy Kolodyazhnyy 28 November 2017 в 06:01
  • 3
    Да, похоже, это упоминается только в man-странице, рядом с C-a |, но не в документах GNU – muru 28 November 2017 в 06:01
  • 4
    Обнаружено странное поведение, которое вы, возможно, захотите упомянуть: если вы наберете, например, layout dump ~/layout, процесс завершится неудачно, ему потребуется полный путь (т. Е. [F2]) – Videonauth 28 November 2017 в 13:37
  • 5
    @Videonauth, поскольку расширение тильды обычно выполняется оболочкой, неудивительно, что данная команда не поддерживает ее внутренне. Некоторые делают, большинство нет. – muru 28 November 2017 в 13:39

Для конкретного случая расположения окна есть команда экрана, чтобы сохранить их в файл: layout dump. Из 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.

Итак, как только вы сделаете компоновку вручную, нажмите Ctrla :, затем введите layout dump /path/to/some/file. Макет будет сохранен в /path/to/some/file, и вы сможете восстановить его в новом сеансе с помощью:

screen -c /path/to/some/file
14
ответ дан 18 July 2018 в 02:27

Для конкретного случая расположения окна есть команда экрана, чтобы сохранить их в файл: layout dump. Из 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.

Итак, как только вы сделаете компоновку вручную, нажмите Ctrla :, затем введите layout dump /path/to/some/file. Макет будет сохранен в /path/to/some/file, и вы сможете восстановить его в новом сеансе с помощью:

screen -c /path/to/some/file
14
ответ дан 24 July 2018 в 17:34

Я придумал следующее, чтобы создать вывод, указанный в моем вопросе, и после превосходного ответа @ muru. Использование layout dump дало мне следующее:

split
focus
split -v
focus
Примечание: расширение Tilde (~) не работает с layout dump, поэтому вместо ~/layout.dmp, например, вам нужно будет использовать /home/<username>/layout.dmp.

Из которого я создал следующее .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
split
focus
#create the bash
chdir /home/server/log
screen
# split vertically and focus onto the new area
split -v
focus
# create the htop screen
screen -t "Htop" htop
# focus twice to end up with the bash area active
focus
focus

Теперь мне нужно только ввести screen и начать мой разыскиваемый макет. Я оставляю это здесь как пример для тех, кто интересуется, но не забывайте проголосовать за ответ @ muru, так как именно он заставил меня решить это.

8
ответ дан 22 May 2018 в 15:50

Я придумал следующее, чтобы создать вывод, указанный в моем вопросе, и после превосходного ответа @ muru. Использование layout dump дало мне следующее:

split focus split -v focus Примечание: расширение Tilde (~) не работает с layout dump, поэтому вместо ~/layout.dmp, например, вам нужно будет использовать /home/<username>/layout.dmp.

Из которого я создал следующее .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 split focus #create the bash chdir /home/server/log screen # split vertically and focus onto the new area split -v focus # create the htop screen screen -t "Htop" htop # focus twice to end up with the bash area active focus focus

Теперь мне нужно только ввести screen и начать мой разыскиваемый макет. Я оставляю это здесь как пример для тех, кто интересуется, но не забывайте проголосовать за ответ @ muru, так как именно он заставил меня решить это.

8
ответ дан 18 July 2018 в 02:27

Я придумал следующее, чтобы создать вывод, указанный в моем вопросе, и после превосходного ответа @ muru. Использование layout dump дало мне следующее:

split focus split -v focus Примечание: расширение Tilde (~) не работает с layout dump, поэтому вместо ~/layout.dmp, например, вам нужно будет использовать /home/<username>/layout.dmp.

Из которого я создал следующее .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 split focus #create the bash chdir /home/server/log screen # split vertically and focus onto the new area split -v focus # create the htop screen screen -t "Htop" htop # focus twice to end up with the bash area active focus focus

Теперь мне нужно только ввести screen и начать мой разыскиваемый макет. Я оставляю это здесь как пример для тех, кто интересуется, но не забывайте проголосовать за ответ @ muru, так как именно он заставил меня решить это.

8
ответ дан 24 July 2018 в 17:34

Другие вопросы по тегам:

Похожие вопросы: