Forrest logo
back to the osascript tool

osascript:tldr:e7854

osascript: Get the bundle identifier of an application (useful for `open -b`).
$ osascript -e 'id of app "${Application}"'
try on your machine

The command "osascript -e 'id of app "${Application}"'" is a command used in the macOS Terminal to retrieve the unique identifier (bundle identifier) of a specific application.

Explanation:

  • "osascript" is the command-line tool in macOS that allows executing AppleScript or JavaScript scripts from the command line.
  • "-e" is an option that specifies that the following argument is a script expression.
  • 'id of app "${Application}"' is an AppleScript expression enclosed in single quotes ('') that retrieves the bundle identifier of the specified application.

Here's how this command works step by step:

  1. The "osascript" command is executed in the Terminal.
  2. The "-e" option indicates that the following argument is a script expression.
  3. Inside single quotes (''), the AppleScript expression 'id of app "${Application}"' is provided.
  4. "${Application}" is a placeholder that should be replaced with the actual name of the application you want to retrieve the identifier for.
  5. The AppleScript expression 'id of app "ApplicationName"' retrieves the bundle identifier of the specified application.
  6. The command prints the result, which is the unique identifier (bundle identifier) of the application named "ApplicationName" or the one specified.

For example, if you want to retrieve the identifier for the Safari web browser application, the command would be: osascript -e 'id of app "Safari"'

The output of the command would be the unique identifier (bundle identifier) of the Safari application, such as "com.apple.Safari".

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the osascript tool