Bash script to open a terminal with multiple tabs on Linux start-up
All of the tasks performed by us after system startup such as opening a browser, MySql etc can be automated by following the steps mentioned below :
1. Write a script:-
[bash]
sleep 1m;gnome-terminal –geometry=150×50 –tab –title="echo" -e "bash -c \"echo "hello";echo "there";exec bash\"" –tab –title="idea" -e "bash -c \"/opt/idea-IU-111.69/bin/idea.sh;exec bash\"" –tab –title="sql" -e "bash -c \"mysql -uroot -pigdefault;\"" –tab –title="firefox" -e "bash -c \"/usr/bin/firefox www.gmail.com;\""
[/bash]
The script above will open a terminal with 4 tabs :
- echo “hello there”
- Idea
- MySql
- Firefox
The script will also set the titles in the terminal for each tab.
One can personalize the above script accordingly.
Description of the script :-
sleep 1m : Executes the script after 1 minute so that system finishes its startup process.
gnome-terminal : Open a terminal.
–geometry=150×50 : Set screen size for terminal.
–tab : Open new tab
–title : Set title for the terminal
-e : Execute the argument inside the terminal.
exec bash : Starts a new bash after executing all the commands. This command is required if you do not want to close the current tab .
2. Save the script anywhere in the file system and make the file executable using the following command:
[bash]
$chmod +x file.sh
[/bash]
3. Add this file to startup applications :-
Go to System > Preferences > Startup Applications
Click on add and in command write-
[bash]
bash path/to/your/file.sh
[/bash]
Close and its done!
Next time when you start your system, all the tasks mentioned in the script will be automated.
Hope this helped!
Hey, Can you please provide the script which can run multiple commands on each tab after opening it.
I’ll be very thankful if you can provide the script which can expect some password after command.
down vote
While playing around, I found that it’s not the command at all – it’s the profile.
Go to:
Go to
Edit | Profiles | (Default) | Edit | Title and Command
and change the “When Terminals Set Their Own Title” option to “Keep initial title”, at the bottom of the list. Now, when you launch a command with a title, it’ll stick around, so your command will work properly.
Nice i took your command and made some additions, its great. Instread of saving the command in file and executing from terminal, i added this command to panel (in centos we have menu bar, ‘add to panel’). Just by clicking this will launch multiple tabs with appropriate paths and setting evironment variables and launching some applications… Thanks for sharing. Your script is really helpful..
One thing to note, –title=”echo” is not working..