產生終端機視窗的腳本突然等待每個視窗關閉然後再開啟下一個視窗

產生終端機視窗的腳本突然等待每個視窗關閉然後再開啟下一個視窗

我最近開始使用 bash 腳本為自己設定終端工作區,前幾天一切正常。我運行該腳本,然後彈出四個、五個或七個終端,它們都精確地位於螢幕上的正確位置,全部都被 cd 到正確的目錄中,可供使用。

今天早上我安裝了 conky,下次我嘗試運行我的腳本時,最奇怪的事情發生了。現在它只會打開第一個視窗。當我關閉該視窗時,第二個視窗將會開啟。當我關閉第一個、第三個,依此類推,直到腳本結束。

所以現在我的腳本除了作為粘貼板供我複製並粘貼到終端之外毫無用處。

這是我的腳本:

#!/bin/bash

if [ $1 = "deploy" ]; then
    cd ~/
    gnome-terminal --geometry=185x41+0+0 --window-with-profile=Colquhoun

    cd ~/Utilities/Ad\ Tag\ Generators
    gnome-terminal --geometry=85x15+1312+0 --window-with-profile=Generator
    cd ~/Utilities
    gnome-terminal --geometry=85x28+1312+280 --window-with-profile=Deployer
    cd ~/Staging
    gnome-terminal --geometry=85x20+1312+730 --window-with-profile=Monitor
fi

if [ $1 = "servers" ]; then
    cd ~/
    gnome-terminal --geometry=89x20+0+0 --window-with-profile=Colquhoun
    gnome-terminal --geometry=89x20+640+0 --window-with-profile=Colquhoun

    gnome-terminal --geometry=89x65+1280+0 --window-with-profile=Colquhoun

    gnome-terminal --geometry=89x20+0+360 --window-with-profile=Colquhoun
    gnome-terminal --geometry=89x20+640+360 --window-with-profile=Colquhoun

    gnome-terminal --geometry=89x20+0+700 --window-with-profile=Colquhoun
    gnome-terminal --geometry=89x20+640+700 --window-with-profile=Colquhoun
fi

if [ $1 = "logchecks" ]; then
    cd ~/
    gnome-terminal --geometry=89x65+0+0 --window-with-profile=Colquhoun
    gnome-terminal --geometry=89x65+640+0 --window-with-profile=Colquhoun
    gnome-terminal --geometry=89x65+1280+0 --window-with-profile=Colquhoun
fi

有人知道為什麼會發生這種情況?為什麼以前沒有發生但現在卻發生了?

答案1

&在每個命令的末端附加一個 ,gnome-terminal以確保每個終端在後台啟動。如果您沒有提早殺死它們,當 conky 退出並殺死所有子進程時,終端將退出。

相關內容