2012-07-18 116 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 

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