Cha*_*ert 68
您还可以让每个选项卡运行set命令.
gnome-terminal --tab -e "tail -f somefile" --tab -e "some_other_command"
Run Code Online (Sandbox Code Playgroud)
utk*_*bey 66
#!/bin/sh
WID=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| awk '{print $5}')
xdotool windowfocus $WID
xdotool key ctrl+shift+t
wmctrl -i -a $WID
Run Code Online (Sandbox Code Playgroud)
这将自动确定相应的终端并相应地打开选项卡.
小智 7
我找到了最简单的方法:
gnome-terminal --tab -e 'command 1' --tab -e 'command 2'
Run Code Online (Sandbox Code Playgroud)
我使用tmux
而不是直接使用终端.所以我想要的是一个简单的命令/ shell文件来构建env
具有多个tmux
窗口的开发.shell代码如下:
#!/bin/bash
tabs="adb ana repo"
gen_params() {
local params=""
for tab in ${tabs}
do
params="${params} --tab -e 'tmux -u attach-session -t ${tab}'"
done
echo "${params}"
}
cmd="gnome-terminal $(gen_params)"
eval $cmd
Run Code Online (Sandbox Code Playgroud)
更复杂的版本(从另一个窗口使用):
#!/bin/bash
DELAY=3
TERM_PID=$(echo `ps -C gnome-terminal -o pid= | head -1`) # get first gnome-terminal's PID
WID=$(wmctrl -lp | awk -v pid=$TERM_PID '$3==pid{print $1;exit;}') # get window id
xdotool windowfocus $WID
xdotool key alt+t # my key map
xdotool sleep $DELAY # it may take a while to start new shell :(
xdotool type --delay 1 --clearmodifiers "$@"
xdotool key Return
wmctrl -i -a $WID # go to that window (WID is numeric)
# vim:ai
# EOF #
Run Code Online (Sandbox Code Playgroud)
以防万一,你想打开
干得好:
gnome-terminal --geometry=73x16+0+0 --window \
--working-directory=/depot --title='A' --command="bash -c ls;bash" \
--tab --working-directory=/depot/kn --title='B' --command="bash -c ls;bash"
Run Code Online (Sandbox Code Playgroud)
(顺便说一句也一样mate-terminal
。)
归档时间: |
|
查看次数: |
137238 次 |
最近记录: |