linux - 如何使用bm脚本中的tmux将屏幕拆分为3

我正在编写一个bash脚本,它将屏幕拆分为3个,并在每个窗格上运行一个命令。
我基本上想运行bash脚本,bash脚本应该将我的屏幕拆分为3,在一个窗格中运行top,在另一个窗格中运行htop,在第三个窗格中运行perl re.pl。
任何帮助或指示都会被理解!


最佳答案:

这样做的直接方法是创建一个分离的会话,创建窗格,然后附加到会话。

# -d says not to attach to the session yet. top runs in the first
# window
tmux new-session -d top
# In the most recently created session, split the (only) window
# and run htop in the new pane
tmux split-window -v htop
# Split the new pane and run perl
tmux split-pane -v perl re.pl
# Make all three panes the same size (currently, the first pane
# is 50% of the window, and the two new panes are 25% each).
tmux select-layout even-vertical
# Now attach to the window
tmux attach-session

您也可以在对tmux的一次调用中执行此操作,但可能没有理由从脚本执行此操作:
tmux new-session -d top \; split-window -v htop \; split-window -v perl re.pl \; select-layout even-vertical \; attach-session