Skip to content

Instantly share code, notes, and snippets.

@mafredri
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mafredri/ce832dcc4e52017e9b62 to your computer and use it in GitHub Desktop.
Save mafredri/ce832dcc4e52017e9b62 to your computer and use it in GitHub Desktop.
Extended subl for SublimeText to open *.sublime-project files if available.
# Detect and open sublime-project files in the provided path, if no parameters
# are provided, open the $PWD. If the parameter is not a directory, call subl
# normally.
_subl() {
local params="$*"
local project
if test -z "$params"; then
params=.
fi
if test -d "$params"; then
project=$(ls "$params"/*.sublime-project 2>/dev/null) 2>/dev/null
if test -n "$project"; then
command subl --project "$project"
else
command subl "$params"
fi
else
command subl "$@"
fi
}
alias subl="_subl"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment