如何使用 bash 脚本中的 tmux 将我的屏幕一分为三
How can I split my screen in 3 using tmux from a bash script
我正在编写一个 bash 脚本,将屏幕一分为三,运行 在每个窗格上都有一个命令。
我基本上想要 运行 bash 脚本和 bash 脚本应该将我的屏幕分成 3 个,并且 运行 在窗格顶部,htop例如,在另一个窗格中和第三个窗格中的 perl re.pl
感谢任何帮助或指点!
我为此使用 tmuxinator。它允许您在配置文件中定义 windows 和每个 window 的窗格,然后您可以将其用于:
tmuxinator start <some-name>
真的很整洁!
(我相信用纯 bash 也可以做到这一点。)
执行此操作的直接方法是创建一个分离的会话,创建窗格,然后附加到会话。
# -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
我正在编写一个 bash 脚本,将屏幕一分为三,运行 在每个窗格上都有一个命令。
我基本上想要 运行 bash 脚本和 bash 脚本应该将我的屏幕分成 3 个,并且 运行 在窗格顶部,htop例如,在另一个窗格中和第三个窗格中的 perl re.pl
感谢任何帮助或指点!
我为此使用 tmuxinator。它允许您在配置文件中定义 windows 和每个 window 的窗格,然后您可以将其用于:
tmuxinator start <some-name>
真的很整洁!
(我相信用纯 bash 也可以做到这一点。)
执行此操作的直接方法是创建一个分离的会话,创建窗格,然后附加到会话。
# -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