Skip to content

Instantly share code, notes, and snippets.

@dsandstrom
Last active June 23, 2016 11:23
Show Gist options
  • Save dsandstrom/5753864 to your computer and use it in GitHub Desktop.
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.
#!/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