自动启动四分割byobu终端

hii*_*ran 2 command-line multiple-monitors gnome-terminal byobu

我想通过自动完成以下操作来避免浪费时间做我的启动仪式:

  1. 打开一个新的终端
  2. 跑卫
  3. 水平拆分,然后垂直拆分两个新窗格(反之亦然)
  4. 为每个窗格运行特定命令

我猜它会是这样的:

gnome-terminal --full-screen -- byobu -S MainSession

byobu-tmux select-pane -t 0
byobu-tmux split-window -v
byobu-tmux select-pane -t 1
byobu-tmux split-window -h
byobu-tmux select-pane -t 0
byobu-tmux split-window -h

byobu-tmux select-pane -t 1
byobu-tmux send-keys "COMMAND"
byobu-tmux select-pane -t 2
byobu-tmux send-keys "COMMAND"
byobu-tmux select-pane -t 3
byobu-tmux send-keys "COMMAND"
byobu-tmux select-pane -t 0
Run Code Online (Sandbox Code Playgroud)

First line on its own would open a new fullscreen terminal and pass the new byobu session command to it. However, I don't know how to connect the rest of the script together. If I put an opening quote before byobu, separate all the commands with ;, and put a closing quote at the end of the script, I get the terminal opened up without byobu, and an error: "Failed to execute child process (No such file or directory)".

In addition, how can I get the terminal opened on a specific monitor? According to gnome-control-center, the monitor I want this to open on is number 3.

hii*_*ran 5

我花了一段时间才弄明白,所以如果有人需要启动脚本来打开多个 byobu 会话,请根据需要使用和修改:

#Create new session. I named this LeftMonitor for obvious reasons
byobu new-session -d -s LeftMonitor

#Select default pane. Probably an unnecessary line of code
byobu select-pane -t 0

#Split pane 0 into two vertically stacked panes
byobu split-window -v

#Select the newly created pane 1. Again, probably unnecessary as the new pane gets selected after a split
byobu select-pane -t 1

#Split pane 1 horizontally to create two side-by-side panes
byobu split-window -h

#Repeat the selection and splitting process with the top half
byobu select-pane -t 0
byobu split-window -h
#At this point, four equally sized panes have been created.

#Select pane to interact with
byobu select-pane -t 1

#Pass a command to the selected pane. I'm using top as the example here.
#Note that you need to type Enter for byobu to simulate pressing the enter key.
byobu send-keys "top" Enter

#Create a new session. Session name is again chosen for obvious reasons
byobu new-session -d -s RightMonitor

#Repeat the same splitting and command issuing processes from the first session.
byobu select-pane -t 0
byobu split-window -h
byobu select-pane -t 1
byobu send-keys "top" Enter
byobu select-pane -t 0
byobu send-keys "top" Enter

#Finally, to be able to actually see anything, you need to launch a terminal for each session
gnome-terminal --full-screen -- byobu attach -t LeftMonitor
gnome-terminal --full-screen -- byobu attach -t RightMonitor
Run Code Online (Sandbox Code Playgroud)

使用您喜欢的文本编辑器保存它,在文件上运行 sudo chmod +x ,并将其添加到您使用的任何启动列表中。