Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I open multiple tabs automatically on terminal in mac os Lion by executing some commands on each tab?

I need to automatically open terminal with multiple tabs and need to execute multiple commands on it.

I know how to do it in ubuntu. but its not working on mac os . Any Idea?

gnome-terminal --tab -e "tail -f somefile" --tab -e "some_other_command"
like image 717
Harikrishnan Avatar asked Oct 14 '25 13:10

Harikrishnan


1 Answers

I can give you a clue.

Using osascript, you can do it.

UPDATE:

One thing you need to understand is, gnome-terminal is for Linux. Gnome is a very popular Desktop environment written for Linux.

Use this oneliner for opening a new tab with $PWD as the working directory:

osascript -e "tell application \"Terminal\"" -e "tell application \"System Events\" to keystroke \"t\" using {command down}" -e "do script \"cd $PWD; clear\" in front window" -e "end tell" > /dev/null

Following one liner will just open a new tab with $PWD as working directory and will execute echo Hi

osascript -e "tell application \"Terminal\"" -e "tell application \"System Events\" to keystroke \"t\" using {command down}" -e "do script \"cd $PWD; echo HI\" in front window" -e "end tell" > /dev/null
like image 77
Suku Avatar answered Oct 17 '25 01:10

Suku



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!