複数のタブを持つ新しいターミナル ウィンドウを開きたいのですが、ウィンドウは開くことができたものの、タブに問題があります。現在の状況は次のとおりです。
#!/bin/bash
# Opens new window, but with only one tab, code after --tab-with... does not work:
gnome-terminal --window-with-profile=Bash -- bash -ic "command; bash;" --tab-with-profile=Bash -- bash -ic "command; bash;"
# This opens a new tab in the same terminal, not the one I created with the above command:
## gnome-terminal --tab-with-profile=Bash -- bash -ic "command; bash;"
# Correctly opens a new window:
gnome-terminal --window-with-profile=Bash -- bash -ic "command; bash;"
exit;
答え1
質問はまだ未解決なので、あなたが求めているものは見つかっていないと思いますが、いずれにしても、この投稿を今後訪問する人にとっては役に立つかもしれません。
やり方は次のとおりです:
gnome-terminal -- bash -c "gnome-terminal --tab; bash"
最後bash
に を付けると、ウィンドウが開いたままになるので、-i
オプションを省略できます。
たとえば、5 つのタブを含むウィンドウを開きたい場合は、単に for ループを挿入するだけです。
// Loop 4 times since opening a window already starts us with 1 tab
gnome-terminal -- bash -c "for i in {1..4}; do gnome-terminal --tab; done; bash"