AppleScript in Bash – How to Create an Alias for an App

aliasapplescriptbashscriptterminal

I need to create an alias on my Desktop to an app in my Applications folder, using a bash script file.

As far as I know, it's only possible with AppleScript.
Unfortunately, my AppleScript skills are non-existent.
I couldn't find a good working example on how to create an alias on my Desktop.

1) How do I create an alias on my Desktop using AppleScript?

2) How do I insert this AppleScript into my bash script file so that it could work in Terminal?

Best Answer

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