How to use AppleScript in a bash script to create an alias for an app?
osascript
will run AppleScript code in your shell. This example uses a HEREDOC to present the code to osascript
.
/usr/bin/osascript <<'EOF'
tell application "Finder"
set myapp to POSIX file "/Applications/Chess.app" as alias
make new alias to myapp at Desktop
set name of result to "Chess.app"
end tell
EOF
Source- Link
Why not skip the Applescript and just create a symbolic link in bash? It behaves exactly like an alias on the desktop except now you can work with it in bash. See this answer for a breakdown of aliases, hard links and sym links.
So, your command would be:
ln -s /path/to/application/MyApp.app /Users/username/Desktop/MyApp
Where MyApp.app and username is the name of the application and the user respectively.