Я использую screen
после того, как вошел в систему с ssh
на моем сервере. На данный момент я настраивал разделение в окне своего компьютера вручную и запускал команды вручную, как показано на следующем снимке экрана:
tail -n 1 -f /home/server/log/access.log
. htop
Есть ли способ сделать это с помощью команд / скрипта так что мне не нужно каждый раз переделывать вручную?
Для конкретного случая расположения окон есть экранная команда для сохранения их в файл: 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.
Итак, как только вы сделаете аранжировку вручную, нажмите Ctrl kbd> a kbd> : kbd>, затем введите layout dump /path/to/some/file
. Макет будет сохранен в /path/to/some/file
, и вы можете восстановить его в новом сеансе с помощью:
screen -c /path/to/some/file
Я придумал следующее, чтобы создать вывод, показанный в моем вопросе и следуя превосходному ответу @ 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, поскольку именно он помог мне решить эту проблему.