BootCamp2019 icon indicating copy to clipboard operation
BootCamp2019 copied to clipboard

Sublime Text [or other editor] button in Mac Finder

Open rickecon opened this issue 5 years ago • 1 comments

@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. image

  1. Open the Automator app on your Mac.
  2. Choose "Application" as the type of Automator document to create.
  3. Choose "Run AppleScript" from the Actions menu.
  4. 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
  1. 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".
  2. Open a finder window, navigate to the /Applications/ folder, press command and click and drag the new SublimeFinderButton.app application to the Finder bar.
  3. 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

rickecon avatar Jul 09 '19 23:07 rickecon

Thank you!

rebekahanne avatar Jul 10 '19 01:07 rebekahanne