This is what I want to accomplish:

  1. I want to open a gnome terminal with five tabs in it
  2. I want to run a set of commands (5 – 10 commands) in each tab automatically
    First tab: shall set clear-case view and after that execute one or more commands
    Second tab: shall login into a server and execute some commands
    Third tab: shall only execute some commands

gnome-terminal --geometry=260x25-0+0 --tab -e "csh -c \"ct setview myViewName; cal\"" –tab --tab --tab (works ok, view is set but no command executed after that)

I have tried to do it this way instead and running this in the script below:

gnome-terminal --geometry 125x18-0-26 --tab -t "some title" -e /home/ekido/Desktop/MyScripts/myScript

exec gnome-terminal --geometry 125x49-0+81 –tab
spawn ssh usert@server
expect "password"
send "*******\r"
expect "user@server100:~>"
send “some command\r"
expect "user@server100:~>"
send “some command"

If I remove the exec gnome-terminal --geometry 125x49-0+81 –tab rows from the example and call a script from some other file, it works fine -- I get logged in to the server and all commands executed. Can anyone help me solve this?

To write a script that I call for every tab is not an option, since I will have 5 terminals with 5-7 tabs in each in the end, and that means it would be 25 to 30 scripts to write (cost more than it helps in my problem).

  • Not that I'm an expert in GNOME Terminal, but the tabs you create should be saved in a profile. After creating the profile, I believe you can script it. See Manage Profiles in the GNOME Help. – eyoung100 Sep 30 '14 at 14:49

This seems to work on my machine:

gnome-terminal --geometry=260x25-0+0 --tab -e "bash -c 'date; read -n1'" --tab -e "bash -c 'echo meow; read -n1' " --tab --tab

Please note, as soon as the processes executed by -e are done running, they will terminate. In this case, bash is loaded, runs whatever commands you pass to it, and immediately exists. I put in the read statements to wait for user input. This way those tabs won't close until you press a key, just so you can see it in this example. Without them, it would look as if only two tabs opened, because the other two would execute and close too quickly.

  • thanks for your answer. Sure, I get to se the output of one command (in this case "date") but I would like to execute several commands, be able to se the output and then continue to write new commands manually in the same tab. – ekido Oct 1 '14 at 8:27

Since bash quits after the command completes, you can call another instance of bash after your command to get an interactive shell:

gnome-terminal  --tab -e "bash -c 'ps -ef; bash'" --tab -e "bash -c 'ls; bash'" --tab -e "bash -c 'top -n 1; bash'"
  • it seems that if I close the terminal the underlying processes dont close automatically, is there a solution to this too? I would like to close the entire window and all tabs with their processes should get a kill – Blub Sep 15 '18 at 7:12

save below as script.sh

#!/usr/bin/env bash

me=$(realpath $0)

"ls -l && echo 'yes'"

if [ $# -eq 0 ];then


xdotool key ctrl+shift+t

if [ $num -gt -1 ]; then
    sleep 1; xdotool type --delay 1 --clearmodifiers "$me $num; ${command}"; xdotool key Return;

add script.sh to $PATH then run it

gnome-terminal -x script.sh


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.