Skip to content

Instantly share code, notes, and snippets.

@allen-munsch
Last active April 19, 2018 17:26
Show Gist options
  • Save allen-munsch/b91e893dd2eb2ed9fa3b299ab37c59a2 to your computer and use it in GitHub Desktop.
Save allen-munsch/b91e893dd2eb2ed9fa3b299ab37c59a2 to your computer and use it in GitHub Desktop.
Open Sublime Text 3 in Terminal Mac OSX

open gui

open /Applications/Sublime\ Text.app

example usage:

# opening a file
open /Applications/Sublime\ Text.app /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dataclasses.py

# opening a file to line 42
open /Applications/Sublime\ Text.app /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dataclasses.py:42

some more docs info open

EXAMPLES
     "open '/Volumes/Macintosh HD/foo.txt'" opens the document in the default application for its type (as determined by LaunchServices).

     "open '/Volumes/Macintosh HD/Applications/'" opens that directory in the Finder.

     "open -a /Applications/TextEdit.app '/Volumes/Macintosh HD/foo.txt'" opens the document in the application specified (in this case, TextEdit).

     "open -b com.apple.TextEdit '/Volumes/Macintosh HD/foo.txt'" opens the document in the application specified (in this case, TextEdit).

     "open -e '/Volumes/Macintosh HD/foo.txt'" opens the document in TextEdit.

     "ls | open -f" writes the output of the 'ls' command to a file in /tmp and opens the file in the default text editor (as determined by LaunchServices).

     "open http://www.apple.com/" opens the URL in the default browser.

     "open 'file://localhost/Volumes/Macintosh HD/foo.txt'" opens the document in the default application for its type (as determined by LaunchServices).

     "open 'file://localhost/Volumes/Macintosh HD/Applications/'" opens that directory in the Finder.

     "open -h NSView" lists headers whose names contain NSView and allows you to choose which ones to open.

     "open -h NSView.h" immediately opens NSView.h.

     "open -h NSView -s OSX10.12" lists headers whose names contain NSView in the MacOSX 10.12 SDK and allows you to choose which ones to open.

nothing fancy just the bin

alias subl='/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl'

add it one of the following .profile, .bashrc, .bash_profile, .zshrc, .zprofile:

echo alias subl='/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl' >> ~/{.zprofile,.profile}
subl -h
Sublime Text build 3143

Usage: subl [arguments] [files]         edit the given files
   or: subl [arguments] [directories]   open the given directories
   or: subl [arguments] -               edit stdin

Arguments:
  --project <project>: Load the given project
  --command <command>: Run the given command
  -n or --new-window:  Open a new window
  -a or --add:         Add folders to the current window
  -w or --wait:        Wait for the files to be closed before returning
  -b or --background:  Don't activate the application
  -s or --stay:        Keep the application activated after closing the file
  -h or --help:        Show help (this message) and exit
  -v or --version:     Show version and exit

--wait is implied if reading from stdin. Use --stay to not switch back
to the terminal when a file is closed (only relevant if waiting for a file).

Filenames may be given a :line or :line:column suffix to open at a specific
location.

questions/comments/suggestions welcome. thnx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment