
我想打開一個終端,將其分成 9 個部分(3x3)並執行一些 bash 腳本。但對於每個終端部分不同的腳本。
這可以使用 perl、python 甚至 bash 來完成嗎?
如何在不使用鍵盤快速鍵的情況下在這些小終端機之間切換?
哦,順便說一下,我正在使用terminator
.如果還有其他終端模擬器可以實現此類功能,是哪一個?
答案1
抄襲我自己,您可以使用所需的設定來設定設定檔(說明改編自這裡):
運行
terminator
並設定您想要的佈局。您可以使用Ctrl+ Shift+E垂直分割窗口,使用Ctrl+ Shift+ O(即 O,而不是零)水平分割視窗。對於此範例,我建立了一個包含 6 個窗格的佈局:右鍵單擊
terminator
視窗並選擇優先。一旦優先視窗已打開,轉到佈局然後單擊添加:這將填充佈局列出您的新佈局:
找到您在佈局中建立的每個終端並點擊它們。然後在右側輸入您要在啟動時在其中執行的命令:
重要的:請注意,該命令後面帶有
; bash
。如果您不這樣做,終端將無法訪問,因為它們將運行您給出的命令並退出。您需要在每個命令後啟動 shell 才能使用終端機。設定完所有命令後,按一下關閉然後退出
terminator
。開啟
terminator
設定檔~/.config/terminator/config
並刪除預設配置佈局下的部分。然後將您建立的佈局名稱變更為預設佈局。它應該看起來像這樣:[global_config] [keybindings] [profiles] [[default]] [layouts] [[default]] [[[child0]]] position = 446:100 type = Window order = 0 parent = "" size = 885, 550 [[[child1]]] position = 444 type = HPaned order = 0 parent = child0 [[[child2]]] position = 275 type = VPaned order = 0 parent = child1 [[[child5]]] position = 219 type = HPaned order = 1 parent = child1 [[[child6]]] position = 275 type = VPaned order = 0 parent = child5 [[[child9]]] position = 275 type = VPaned order = 1 parent = child5 [[[terminal11]]] profile = default command = 'df -h; bash' type = Terminal order = 1 parent = child9 [[[terminal10]]] profile = default command = 'export foo="bar" && cd /var/www/; bash' type = Terminal order = 0 parent = child9 [[[terminal3]]] profile = default command = 'ssh -Yp 24222 [email protected]' type = Terminal order = 0 parent = child2 [[[terminal4]]] profile = default command = 'top; bash' type = Terminal order = 1 parent = child2 [[[terminal7]]] profile = default command = 'cd /etc; bash' type = Terminal order = 0 parent = child6 [[[terminal8]]] profile = default command = 'cd ~/dev; bash' type = Terminal order = 1 parent = child6 [plugins]
最終結果是,當您運行時,terminator
它將打開 6 個窗格,每個窗格都已運行或正在運行您指定的命令:
此外,您可以根據需要設定任意多個不同的配置文件,並使用-p
給出配置文件名稱的開關啟動終結器,或者在啟動後手動切換到您想要的任何配置文件。
答案2
您是否正在尋找終端多工器 tmux。
答案3
當我使用terminator
這個 rc 檔案時,我用它來打開一堆終端並運行應用程式。將其保存到.config/terminator/config
.
[global_config]
title_hide_sizetext = True
enabled_plugins = LaunchpadCodeURLHandler, APTURLHandler, LaunchpadBugURLHandler
[keybindings]
[profiles]
[[default]]
font = DejaVu Sans Mono 9
cursor_blink = False
scrollback_infinite = True
[layouts]
[[default]]
[[[root]]]
position = -4:0
type = Window
order = 0
parent = ""
size = 1072, 1884
[[[grand]]]
position = 536
type = HPaned
order = 0
parent = root
[[[left]]]
position = 942
type = VPaned
order = 0
parent = grand
[[[right]]]
position = 942
type = VPaned
order = 1
parent = grand
[[[terminal1]]]
profile = default
type = Terminal
order = 0
parent = left
command = "cd ~/code/foo; bash"
[[[terminal2]]]
profile = default
type = Terminal
order = 1
parent = left
command = "cd ~/bar/baz; bash"
[[[terminal3]]]
profile = default
type = Terminal
order = 1
parent = right
command = ""
[[[terminal4]]]
profile = default
type = Terminal
order = 0
parent = right
command = "cmus; bash"
[plugins]
編輯:請注意,此資訊可能來自 Terdon 在更早的線程上的帖子。我已經使用這個設定幾個月了,但 Terdon 的帖子看起來非常熟悉!
答案4
用於分割終結者終端模擬器的包裝腳本 https://github.com/AlekseyChurdov/terminator-split