问题的说明
我在使用Ubuntu 9.04 x64。 在写这篇文章的时候:
gome-terminal----tab
在终端上,我想在同一个终端窗口打开新的标签。 打开新的窗口。
其目的是在新窗口中打开新的选项卡。 也就是说,如果是我写的:
gome-terminal----tab----tab
将打开一个包含两个选项卡的新窗口。
因此,问题是如何使用gnome-terminal命令在当前窗口中打开新的选项卡。
最佳解决方案
#! 往常的仙人掌/sh
wid=$ (xprop-root|grep ' _ net _ active _ window (window )| awk '{print $5} )
xdotool windowfocus $WID
xdotool key ctrl shift t
wmctrl -i -a $WID
这将自动确定合适的终端,并相应地打开选项卡。
次优解决方案
也可以在每个选项卡上运行set命令。
Gome-terminal-- ta B- e ' tail-fsomefile '-- ta B- e ' some _ other _ command '
第三个解决方案
我找到了最简单的方法:
gnome-terminal---ta B- e ' command1'---ta B- e ' command2'
我用tmux而不是直接用终端。 因此,我真正想要的是一个简单的命令/shell文件,用于使用多个tmux窗口构建开发env。 shell代码如下。
#! 平时的仙人掌/bash
tabs='adb ana repo '
gen_params () }
local params=' '
for tab in ${tabs}
德奥
params=' $ { params }-- ta B- e ' tmux-u attach-session-t $ { tab } '
唐
echo '${params} '
}
cmd=' gnome-terminal $ (gen _ params ) '
eval $cmd
第四种方法
更详细的版本(从其他窗口使用) :
#! 平时的仙人掌/bash
延迟=3
term _ PID=$ (echo ` PS-c gnome-terminal-opid=|head-1 ` ) # get first gnome-terminal's PID
wid=$ (WM ctrl-LP|awk-vpid=$ term _ PID ' $3==PID { print $ 1; 退出; () ) #获取窗口id
xdotool windowfocus $WID
xdotool key alt t # my key map
xdotoolsleep $ delay # itmaytakeawhiletostartnewshell : (
xdotooltype---delay1--- clear modifiers ' $ @ '
xdotool key Return
WM ctrl-I-a $ wid # gotothatwindow (wid isnumeric ) )。
# vim:ai
# EOF #
参考资料