Open the program in a new terminal tab using the shell script

This is a small shell script that 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 is it, opens a new terminal for each program. What I want to do is open a new terminal tab instead of a terminal. How am I supposed to do this?

+4
source share
2 answers

I think your best option is to use tmux to do the job. Here is just a quick example and a step-by-step explanation for this. Here I use only vertical splits, which can be confusing, you should read in the tmux man page to see how to select-panels .

  • First create a new tmux session in separate mode
  • Then send the appropriate command to start your first program
  • Create a new vertical delimiter
  • Send the appropriate command to start the second program
  • etc.
  tmux new-session -d -s foo
 tmux send-keys -t foo 'optirun yarpserver' Enter
 tmux split-window -v -t foo
 tmux send-keys -t foo 'optirun iCub_SIM' Enter
 tmux split-window -v -t foo
 tmux send-keys -t foo 'optirun simCartesianControl' Enter
 tmux split-window -v -t foo
 tmux send-keys -t foo 'optirun iKinCartesianSolver --context simCartesianControl / conf --part left_arm' Enter

Hope this helps you.

0
source

This thread is really old, but if someone comes here, I leave the bash script that I created to launch several 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 to the array and execute.

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

0
source

Source: https://habr.com/ru/post/1440631/


All Articles