【问题标题】:Gedit open in new window then new tabGedit 在新窗口中打开,然后在新选项卡中打开
【发布时间】:2012-07-18 18:57:37
【问题描述】:

我要做的是让 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--name--sm-client-id 与gedit 一起使用。我也尝试过使用coproc,但确实没有用。任何帮助将不胜感激。谢谢。

【问题讨论】:

  • 不清楚你在问什么。我认为 Gedit 如果您不使用 & 符号,则可以工作,尽管该功能在您关闭编辑器之前不会退出。但是如果你把 & 号留在里面,到底会发生什么?
  • 加入 & 符号后,第一个文件在新窗口中打开,而另一个文件在另一个 Gedit 会话中打开。

标签: bash tabs gedit new-window


【解决方案1】:

好的,我就是这样解决的:

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。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-02
    • 2011-01-10
    • 1970-01-01
    • 1970-01-01
    • 2015-04-19
    • 2017-11-09
    • 2013-03-22
    • 1970-01-01
    相关资源
    最近更新 更多