Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hujunfeng/ee626bf37ac5aea77915c6a71da20b29 to your computer and use it in GitHub Desktop.
Save hujunfeng/ee626bf37ac5aea77915c6a71da20b29 to your computer and use it in GitHub Desktop.
Raycast Script Command: Open Finder Selection in File Search
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Open Finder Selection in File Search
# @raycast.mode silent
#
# Optional parameters:
# @raycast.packageName Utilities
# @raycast.icon 📂
tell application "Finder"
set selectedItems to selection
if selectedItems is not {} then
set firstItem to item 1 of selectedItems
set filePath to POSIX path of (firstItem as alias)
set encodedFilePath to (filePath as string)
if encodedFilePath ends with "/" then
set encodedFilePath to text 1 thru -2 of encodedFilePath
end if
set raycastURL to "raycast://extensions/raycast/file-search/search-files?fallbackText=" & encodedFilePath
do shell script "open " & quoted form of raycastURL
else
display notification "No file selected in Finder." with title "File Not Selected"
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment