Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sublime Text [or other editor] button in Mac Finder #15

Open
rickecon opened this issue Jul 9, 2019 · 1 comment
Open

Sublime Text [or other editor] button in Mac Finder #15

rickecon opened this issue Jul 9, 2019 · 1 comment

Comments

@rickecon
Copy link
Contributor

rickecon commented Jul 9, 2019

@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

@rebekahanne
Copy link
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants