BootCamp2019
BootCamp2019 copied to clipboard
Sublime Text [or other editor] button in Mac Finder
@fediskhakov gave me a great Mac hack yesterday. This allows you to have a Sublime Text button in your Finder window on a Mac that you can either drag files to it to open them or click on it to open a blank file.
- Open the Automator app on your Mac.
- Choose "Application" as the type of Automator document to create.
- Choose "Run AppleScript" from the Actions menu.
- Paste the following code script into the AppleScript window.
on run
set st2 to POSIX path of (path to application "Sublime Text")
set subl to st2 & "Contents/SharedSupport/bin/subl"
tell application "Finder"
copy selection to theSelected
set outputPathList to {}
repeat with anItem in theSelected
copy "'" & ((POSIX path of (anItem as alias)) as string) & "'" to end of outputPathList
end repeat
set AppleScript's text item delimiters to " "
set currentPath to outputPathList as string
set AppleScript's text item delimiters to ""
if currentPath is equal to "" then
set currentPath to "'" & (POSIX path of (target of front window as string)) & "'"
end if
end tell
tell current application to do shell script "'" & subl & "' -n " & currentPath
end run
- In the Automator menu, select File, then Save..., then name the application "SublimeFinderButton.app", save it to the
/Applications/
folder, and choose the file format of "Application". - Open a finder window, navigate to the
/Applications/
folder, press command and click and drag the newSublimeFinderButton.app
application to the Finder bar. - Finally, change the icon to the Sublime Text icon by right clicking on the "Applications/Sublime Text.app" and selecting Get info option. Click on the Sublime Text icon in the upper left of the Get info window. A blue outline will appear around it. Press command-c to copy the icon to clipboard. Then right click on your new "Applications/SublimeFinderButton.app" application and click on the Get info option. Click on the Automator icon in the upper left of the Get info window. A blue outline will appear around it. Press command-v to paste the Sublime Text icon.
Enjoy
Thank you!