NicholasByDesign
NicholasByDesign

Reputation: 801

macOs bash/terminal command to open terminal, change directory and run command

I am writing what I assume is pretty easy bash script file. Although I cannot seem to do the following combination:

open new terminal instance > cd to directory > run command in that terminal instance

I got as far as:

open -b com.apple.terminal /path/I/want/

but if I try something like:

open -b com.apple.terminal /path/I/want/ && /path/to/command someCommand

It runs in the original window instance and not the new one. Tried some other variations of that as well with no success

Upvotes: 4

Views: 4852

Answers (1)

NicholasByDesign
NicholasByDesign

Reputation: 801

I managed to solve this with the following:

osascript -e "tell application \"Terminal\" to do script \"cd /directory/to/open && /path/to/command command\""

Upvotes: 2

Related Questions