-
-
Save kiub/56ef04cccec3a9931bd7 to your computer and use it in GitHub Desktop.
This file contains 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
# bash function, usage: $ st -p [projectname] -opt2 -opt3 | |
function sublime() { | |
if [ -n "$1" -a -n "$2" ]; then # if more than one argument | |
if [ "$1" = "-p" -o "$1" = "--project" ]; then # if arg1 is -p or --project | |
local projectfile="$2" | |
[[ $projectfile != *.sublime-project ]] && projectfile="$2.sublime-project" # detect if arg2 already includes the ext | |
if [ -e $projectfile ]; then # does project file exist? | |
subl -n --project $projectfile ${*:3} # open project file, in new window, include trailing args | |
#echo "project specified, and project file exists, execute: subl -n --project $projectfile ${*:3}" | |
else | |
subl ${*:3} # open sublime but drop -p||--project and project name from args | |
#echo "project specified, but project file doesn't exist, execute: subl ${*:3}" | |
fi | |
else | |
subl $* # open sublime and pass args as usual | |
#echo "project argument not passed, execute: subl $*" | |
fi | |
else | |
subl $* # open sublime and pass args as usual | |
#echo "only 1 argument passed, execute: subl $*" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment