Search code examples
node.jsterminalosascript

osascript opens a new window instead of just a new tab


I'm trying to open a new tab and run a command in it. Instead, this opens a new tab which opens a new window and then runs the command... What am I doing wrong?

exec(`osascript -e 'tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down' -e 'tell application \"Terminal\" to do script \"export KUBECONFIG=${basePath}/${answer.clustername}/${configfile}\"'`);

Solution

  • I had to add in window 1 at the very end for it to work in the new tab (instead of opening a new window).