gpt4 book ai didi

linux - 使用多个选项卡和不同的命令打开新的 gnome-terminal (v3.28+)

转载 作者:行者123 更新时间:2023-12-02 17:10:18 24 4
gpt4 key购买 nike

Ubuntu 14(v3.6?)和 Ubuntu 18(v3.28)附带的版本之间 gnome-terminal 的行为似乎发生了变化。

我有一个脚本,可以打开一个新的 gnome 终端,其中有一堆选项卡设置到不同的目录以供我开发,目前第一个选项卡运行一个脚本。使用选项卡打开 gnome 终端的命令如下所示:

gnome-terminal \
--tab --command="myscript.sh" \
--tab --working-directory="<some dir 1>" \
--tab --working-directory="<some dir 2>" \
...

这在 Ubuntu 14(v3.6?)附带的 gnome-terminal 版本中完美地工作。

但是在 Ubuntu 18 (v3.28) 附带的 gnome-terminal 版本中,有几件事发生了变化:

  1. 除非我添加 --window 选项,否则选项卡将在当前的 gnome 终端中打开,而不是新的。不幸的是,添加 --window 选项会打开一个初始空白选项卡。是否可以打开一个仅包含我指定的选项卡的新窗口?
  2. 我现在收到以下通知(尽管它的功能与以前一样):

    # Option “--command” is deprecated and might be removed in a later version of gnome-terminal.
    # Use “-- ” to terminate the options and put the command line to execute after it.

    根据本指南更改我的脚本会更改行为,以便将命令发送到所有选项卡,而在此之前我可以将唯一的命令应用于每个选项卡。这是否意味着每个选项卡运行单独命令的功能已被弃用,或者我是否遗漏了某些内容?

我很欣赏有关如何更改我的脚本以支持较新的 gnome 终端中的旧行为的建议。

最佳答案

1) 使用 --window 作为您的第一个选项卡

gnome-terminal \
--window -t 'Tab 1' \
--tab -t 'Tab2' --working-directory="<some dir 1>" \
--tab -t 'Tab3' --working-directory="<some dir 2>" \
...

不幸的是,这将只允许使用新设计传递一个命令,并且窗口/选项卡在完成时关闭(我不确定这是否是之前的行为)

2)如果您不关心命令完成后选项卡的关闭,您可以这样做:

$ gnome-terminal --window -- ./mytabs.sh

mytabs.sh

#!/bin/bash
gnome-terminal --tab -t 'Tab 1' -- ./myscript.sh
gnome-terminal --tab -t 'Tab 2' --working-directory="<some dir 1>"
gnome-terminal --tab -t 'Tab 3' --working-directory="<some dir 2>"

这将从上面的代码中创建的窗口中的脚本中打开每个选项卡。这是一个痛苦的事情,因为您要么必须键入第一个命令,要么创建第二个脚本。

关于linux - 使用多个选项卡和不同的命令打开新的 gnome-terminal (v3.28+),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52764599/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com