r/applescript • u/_Kitchen_ • Jun 25 '21
2 commands in the same terminal window
With an AppleScript I am trying to open a terminal window and set the terminal to cd into certain folders. I want the terminal to cd into multiple folders. but it keeps opening up 2 windows and doing the 2 commands in 2 separate windows.
set desktop_folder to "$HOME/Desktop"
tell application "Terminal"
do script "cd desktop"
do script "cd myfolder"
end tell
how can i set it so that the terminal will execute these commands in the same window?
2
Upvotes
View all comments
Show parent comment
1
u/_Kitchen_ Jun 25 '21
Defining window 1 actually worked thanks running below:
tell application "Terminal"
activate
set shell to do script "cd desktop" in window 1
do script "cd project34" in shell
do script "python3 main.py" in shell
end tell
however i did run into the error of the terminal not being able to find window 1. for some reason. i had to close all existing terminal windows to get it to work.