
我有一個 bash 腳本,它可以啟動三個進程,如下所示:
CD FOO_DIR && ./run-foo
CD BAR_DIR && ./run-bar
CD BAZ_DIR && ./run-baz
我想要一個工具,將父 shell 分成三個部分(水平或垂直 - 沒有區別),並分別顯示每個部分中每個子進程的輸出。
存在這樣的工具嗎?
答案1
正如已經說過的,螢幕應該滿足您的需求。
建立一個如下所示的螢幕設定檔:
startupmessage off
split
split
screen -t top top # -t <title> <command>
screen -t netstat watch netstat -tanp
screen -t date watch date
select top # In the first screen show the screen titled 'top'
focus down # Focus down to next screen
select netstat # Show screen titled 'netstat'
focus down # Focus down to the next screen
select date # Show the screen titled date
我們稱這個文件為screen_run
。然後只需運行螢幕即可。 -c 選項指定要使用的設定檔:
screen -c screen_run
如果您想要垂直分割,您應該能夠使用split -v
代替split
。
答案2
除此之外screen
,您可能還想查看tmux
以及。每種方法都有其優點和缺點,與另一種方法相比,您可能更喜歡其中一種處理分裂的方法。