I cannot split the terminal into 5 terminals (vertical or horizontal). I don't understand why the split crashes or does nothing every time I try to do it in the bash or screenrc script. I don't want to do the split with the keyboard shortcuts but directly in the executed files (split -v or split -h, or screen -X split -v).
script.sh
sudo podman network create podman
sudo podman login xxxxx
rabbitmq="docker.io/rabbitmq:latest"
podman1="xxxxx"
podman2="xxxxx"
podman3="xxxxx"
podman4="xxxxx"
sudo podman pull $rabbitmq $podman1 $podman2 $podman3 $podman4
sudo podman stop -i $rabbitmq $podman1 $podman2 $podman3 $podman4
SCREENS_TEST=$(sudo screen -ls | grep run_screen | wc -l)
if [ $SCREENS_TEST -eq 0 ]
then
sudo screen -m -dS run_screen -c .screenrc
else
sudo screen -S run_screen -X quit
sudo screen -m -dS run_screen -c .screenrc
fi
sudo screen -S run_screen -x -X screen -t rabbitmq bash -c "sudo podman run -it --rm --name rabbitmq --network podman --hostname rabbitmq -p 5672:5672 $rabbitmq"
sudo screen -S run_screen -x -X screen -t podman1 bash -c "sudo podman run --rm -it --env-file=attributs.env $podman1"
sudo screen -S run_screen -x -X screen -t podman2 bash -c "sudo podman run --rm -it --env-file=attributs.env $podman2"
sudo screen -S run_screen -x -X screen -t podman3 bash -c "sudo podman run -it --rm --env-file=attributs.env -p 8000:80 $podman3"
sudo screen -S run_screen -x -X screen -t podman4 bash -c "sleep 15 && sudo podman run -it --rm --env-file=attributs.env $podman4"
sudo screen -r run_screen
.screenrc
vbell off
scrollback 10000
term xterm-256color
nonblock 5
shell -${SHELL}
caption always "%3n %t%? @%u%?%? [%h]%?%=%c"
startup_message off
bind ' ' windowlist -b
You made a couple of mistakes. So it's not simple.
First, you didn't do any splits in your commands. Second, you send commands wrongly.
Let's make
new.screenrc. Modify the screenrc's layout as what you like in the code.layout save defaultssetting prevents losing layouts.shell bashmakes bash the default shell.new.screenrc
new_script.sh
This code has a con which is that the screenrc doesn't make a layout with
-d -moption. But there is a tactic to recover the layout.But in an interactive shell, it works great.
^Mat the end of the commands you want to run does not consist of^andM. This is the meta character^M, which you make byCtrl-vandRET(RET is a return key or an enter key) orCtrl-vandCtrl-m. Without the character, the gnu screen read your command and doens't execute it because without the special character, the gnu screen won't type enter in the prompt.But you can just use
\rinstead of^MI replace your commands which have
-dmoption with mine. The screenrc will detach the session.The tactic to recover the layout if you run the
new.screenrcwith-d -moption.Sometimes, you use the commands like this
/usr/local/bin/screen -d -m -c /Users/user/my_script/GNUscreen/backup_monitor.screenrcto start the screen session detached.As I mentioned before, in this case, the gnu screen won't split windows, even the screen makes the screens. If you reattach the session, there is no split window. you just have to source the your spliting movement in the screen session.
new_reload_split.screenrc
:source new_reload_split.screenrc