0

What I'm trying to do is make Gedit open a new window then in that new window open a new tab while having Gedit already open. The script I'm writing is a little big, 570 lines, so here is kind of an except of it.

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

I figured out, that it is the ampersand (&) at the end. But as noted, that is very important because when I run my script I run it in KVIrc. If I take out the &, KVIrc waits for Gedit to completely close. I tried using, -s, --name and --sm-client-id with gedit. I tried also using coproc, that really didn't work. Any help would be greatly appreciated. Thank You.

vis.15
  • 751
  • 8
  • 18
  • It's not clear what you are asking. I gather that `Gedit` works if you leave the ampersand out, although the function doesn't exit until you close the editor. But if you leave the ampersand in, what exactly happens? – chepner Jul 18 '12 at 22:44
  • With the ampersand in, the first file opens in a new window, while the other file opens in another Gedit session. – vis.15 Jul 19 '12 at 01:31

1 Answers1

0

Ok, this is how I solved it:

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 &
}

The format for this command is as follows:

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

where you can have as many $Files you want.

vis.15
  • 751
  • 8
  • 18