How can I create a Desktop shortcut that launch a shell script for Mac ?

Comments

1 comment

  • Avatar
    wojciechka

    In this case, the best approach is to create your own .app bundle (i.e. Script.app directory with Contents/Info.plist and all other required resources). You can put the script to run in the Info.plist file - such as:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>English</string>
        <key>CFBundleExecutable</key>
        <string>script.sh</string>
        <key>CFBundleGetInfoString</key>
        <string>Sample script</string>
        <key>CFBundleIconFile</key>
        <string>script.icns</string>
        <key>CFBundleIdentifier</key>
        <string>com.example.script</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundleName</key>
        <string>Sample script</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
        <string>3.0</string>
        <key>CFBundleSignature</key>
        <string>Sample Script</string>
        <key>CFBundleVersion</key>
        <string>3.0</string>
    </dict>
     </plist>
    

    Then you need to create your script as Contents/MacOS/script.sh. Similarly, icons should go to Contents/Resources.

    You can find more information in Bundle Programming Guide from Apple.

Please sign in to leave a comment.