2012-07-18 106 views
0

我想要做的是讓Gedit打開一個新窗口,然後在新窗口中打開一個新標籤頁,同時Gedit已經打開。我正在寫的劇本有點大,有570行,所以這裏除了它以外,還有一些。Gedit在新窗口中打開,然後新標籤

File1="test" 
File2="test2" 
function Gedit() { 
    local newwindow 

    if [ "$2" == "yes" ]; then 
     newwindow="--new-window" 
    fi 

    gedit $newwindow $1 & # & is Very Important b/c of KVIrc 
} 
function FunctionA { 
    Gedit $a "yes" 
    Gedit $b 
} 

FunctionA 

我想出,它是在最後的符號(&)。但是如前所述,這非常重要,因爲當我運行我的腳本時,我在KVIrc中運行它。如果我拿出&,KVIrc等待Gedit完全關閉。我嘗試使用帶有gedit的-s,--name--sm-client-id。我也嘗試使用coproc,那真的沒用。任何幫助將不勝感激。謝謝。

+0

目前還不清楚你在問什麼。我認爲'Gedit'可以工作,如果你離開&符號,雖然函數不會退出,直到你關閉編輯器。但是,如果你將&符號放入,究竟發生了什麼? – chepner 2012-07-18 22:44:20

+0

在&符號中,第一個文件在新窗口中打開,而另一個文件在另一個Gedit會話中打開。 – 2012-07-19 01:31:38

回答

0

好吧,這是我如何解決它:

function OpenWithGedit() { 
local newwin=$1 
shift 
local outfile ofile i 
local newwindow 

#splits [email protected] into two parts 
ofile=${@:1:$(($#/2))} 
outfile=${@:$(($#/2+1)):$#} 

if [ "$newwin" == "yes" ]; then 
    newwindow="--new-window" 
fi 

for i in $outfile 
do 
    SayE "Gedit" $i #echos $i with some format 
done 
gedit $newwindow $ofile & 
} 

此命令的格式如下:

OpenWithGedit "yes" $File1 $File2 $File3 $File1Out $File2Out $File3Out 

在那裏你可以有很多$文件你想要的。

相關問題