Reputation: 11
Issue: Create a script that opens a terminal window with multiple tabs, each tab requires a different title to identify its purpose, in addition each tab should display a specific commmand (will not execute the command, the user will need to hit Enter to execute the command).
Example: The user needs to execute 3 commands: ifconfig
, route -n
and top
, the user executes the script and it opens the terminal with 3 tabs, the first tab shows in the title Network
and the prompt shows root$ ifconfig
, the second tab shows in the title Routing
and the prompt is like root$ route -n
, the third tab shows the title Performance
and the prompt shows root$ top
. The commands are not running when the script is executed, the user needs to go into each tab and manually hit "Enter" to execute each command.
I am using the following script to open the terminal with multiple tabs, but am stuck trying to get the other features working, any assistance will be highly appreciated:
#bin/bash
tab="--tab"
cmd="bash -c 'pwd';bash"
foo=""
for i in 1 2 3; do
foo+=($tab -e "$cmd")
done
gnome-terminal "${foo[@]}"
exit 0
Upvotes: 1
Views: 1007
Reputation: 6372
You can save the state of your terminal using:
gnome-terminal --save-config=FILE
And call the load with:
gnome-terminal --load-config=FILE
Where FILE is the filename you would like to save.
So you can open 3 tabs and give them names etc, then save the config and in your script you can load it.
On the saved file you can edit properties like:
WorkingDirectory=
Title=
As for displaying a command and not running it, I don't have a solution.
You can check this: http://www.techrepublic.com/blog/linux-and-open-source/how-to-make-your-own-gnome-terminals/
Upvotes: 1