-
-
Save dsandstrom/5753864 to your computer and use it in GitHub Desktop.
Bash script to open Sublime Text project. Defaults to opening current directory if no file given. If file/folder given, opens that.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ "$#" -eq "0" ] ; then | |
| for file in *sublime-project | |
| do | |
| if [ -f $file ] ; then | |
| # if no arguments, find if there is a project file in the current directory | |
| filename="${file%.*}" | |
| echo "Opening project: $filename" | |
| /opt/sublime_text_2/sublime_text --class=sublime-text-2 -n $file & | |
| exit 0 | |
| else | |
| # if no project file, just open the current directory | |
| echo "Opening current directory" | |
| /opt/sublime_text_2/sublime_text --class=sublime-text-2 -n . & | |
| exit 0 | |
| fi | |
| done | |
| fi | |
| # if arguments given, run as normal | |
| /opt/sublime_text_2/sublime_text --class=sublime-text-2 "$@" -n | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment