Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open a program in new terminal tab using shell script

Tags:

shell

This is a small shell script i wrote .

x-terminal-emulator -e "optirun yarpserver" &
sleep 6
x-terminal-emulator -e "optirun iCub_SIM" &
sleep 60
x-terminal-emulator -e "optirun simCartesianControl" &
sleep 30
x-terminal-emulator -e "optirun iKinCartesianSolver --context simCartesianControl/conf --part left_arm" &

What this does is , opens a new terminal for each program . What i want to do is open new terminal tab instead of a terminal . How should i go about doing this ?

like image 997
rajat Avatar asked Nov 13 '22 20:11

rajat


1 Answers

This thread is really old but if someone comes here, I leave a bash script that I created to launch multiple tabs to run different commands:

#!/bin/bash

# Array of commands to run in different tabs
commands=(
    'tail -f /var/log/apache2/access.log'
    'tail -f /var/log/apache2/error.log'
    'tail -f /usr/local/var/postgres/server.log'
)

# Build final command with all the tabs to launch
set finalCommand=""
for (( i = 0; i < ${#commands[@]}; i++ )); do
    export finalCommand+="--tab -e 'bash -c \"${commands[$i]}\"' "
done

# Run the final command
eval "gnome-terminal "$finalCommand

Just add the commands in the array and execute.

Source: http://joaoperibeiro.com/command-line-script-to-launch-multiple-tabs/

like image 95
Joaopcribeiro Avatar answered Dec 26 '22 23:12

Joaopcribeiro