0

我要做的是让 Gedit 打开一个新窗口,然后在该新窗口中打开一个新选项卡,同时 Gedit 已经打开。我正在写的脚本有点大,570 行,所以这里是一个例外。

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 完全关闭。我尝试使用 ,-s--namegedit --sm-client-id。我也尝试过使用coproc,这真的没有用。任何帮助将不胜感激。谢谢你。

4

1 回答 1

0

好的,这就是我解决它的方法:

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

#splits $@ 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

您可以在其中拥有任意数量的 $Files。

于 2012-07-18T19:26:42.427 回答