我想打開新的終端窗口,每個窗口都有多個選項卡,雖然我已成功打開窗口,但我在使用選項卡時遇到了問題。我目前擁有的是:
#!/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"