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?

  • Did Apple not release a new version of that AppleScript editor which would observe your actions and make AppleScripts for you? Even if you needed to tweak them afterwards, such a thing was helpful for me when I was first learning AppleScript in the OS 7 era. – can-ned_food Mar 31 '17 at 3:11

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

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .