Fetch Bundle ID of Mac App with Raycast script

How to use Raycast script command feature to create a workflow to get the bundle ID for any mac app.

Sometimes when I try to write and modify some tools (usually CLI) for some apps on my mac, I find myself wanting to get the bundle ID for this particular app. This is one specific way of pointing to this app. Of course apple provides the great utility osascript which is a command line tool to run AppleScript. You can get this from running the following in your terminal

osascript -e 'id of app "{App_Name}"'

And of course that can be automated a little bit more by creating a shell script and passing the app name as an argument. Something like the following get_bundle_id.sh file can work


osascript -e "id of app \"$1\""

And then you can run it like this (i.e. for finder)

./get_bundle_id.sh "finder"

which will give you the following output


But I wanted to make it even easier and faster to get the bundle ID for any app. So I created a script command in Raycast to do that. Fortunately, Raycast has a great documentation on how to create a script command. So I followed the steps there and created a script command that takes the app name as an argument and returns the bundle ID for that app. You can find the script command here.

The idea is simple. we can use the default template for a script command with argument and modify it to our needs. So I created a script command with the following code


# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Bundle ID
# @raycast.mode compact

# Optional parameters:
# @raycast.icon 🤖
# @raycast.argument1 { "type": "text", "placeholder": "App Name" }
# @raycast.packageName App Bundle ID

# Documentation:
# @raycast.description Get bundle id for any app installed
# @raycast.author melashri
# @raycast.authorURL https://raycast.com/melashri

osascript -e 'id of app "'"$1"'"'

Then save the file in some location on your mac. Then you can access the script command from raycast under script commands section. the name will be Bundle ID which is the value of @raycast.title in our code. Now you can access this as any other raycast object and when you are on it it will prompte you to enter the app name. Once you enter the app name it will return the bundle ID for that app. This is a screenshot of how it looks like

Bundle ID script command

And then it will give you the bundle ID but the output of the script dissapears in few seconds. Unfortunately, as of the current version, Raycast does not provide a built-in feature to increase the output display time or disable it from disappearing. The output of the script command is designed to auto-dismiss after a few seconds. But you can use the cmd + c to copy the output to your clipboard.

#Raycast   #Mac   #Bundle ID   #Script Command   #Workflow