Sie können auch festlegen, dass jeder Tab einen set-Befehl ausführt.
gnome-terminal --tab -e "tail -f somefile" --tab -e "some_other_command"
Eine etwas aufwändigere Version (um sie von einem anderen Fenster aus zu verwenden):
#!/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 "[email protected]"
xdotool key Return
wmctrl -i -a $WID # go to that window (WID is numeric)
# vim:ai
# EOF #
Ich fand den einfachsten Weg:
gnome-terminal --tab -e 'command 1' --tab -e 'command 2'
Ich verwende tmux
anstatt das Terminal direkt zu verwenden. Was ich also will, ist wirklich eine einzige und einfache Befehls-/Shell-Datei, um die Entwicklung env
zu erstellen mit mehreren tmux
Fenster. Der Shell-Code lautet wie folgt:
#!/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
#!/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
Dadurch wird automatisch das entsprechende Terminal ermittelt und die entsprechende Registerkarte geöffnet.