I stumbled upon this post after 1/2 of day of Googling, questioning LLMs, and trial and error with shell & AppleScript commands. These 6 lines are exactly what I needed, and are just a small amount different than what I tried multiple times earlier in the day, thank you!
I am trying to execute this within a bash script and its not working so far;
osascript <<EOD
set theAppPath to “/Applications/Audacity.app”
try
set theShellScript to “defaults write com.apple.dock persistent-apps -array-add 'tile-datafile-data_CFURLString” & theAppPath & “_CFURLStringType0'”
do shell script theShellScript
do shell script “killall -HUP Dock”
end try
EOD
I am assuming that I am missing something simple, if you could point it out I appreciate it. Otherwise I am going to save it as a separate .scpt and just call it from the bash script.