我想打开一个终端,将其分成 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