Skip to content

Instantly share code, notes, and snippets.

@trisweb
Forked from bcarlin/.bashrc
Last active July 12, 2019 15:41
Show Gist options
  • Save trisweb/3d0c26b27cf9123fb2006a1365ce3277 to your computer and use it in GitHub Desktop.
Save trisweb/3d0c26b27cf9123fb2006a1365ce3277 to your computer and use it in GitHub Desktop.
Alias for sublime text to automatically open a project when calling "subl" if a .sublime-project file is found in the current directory. This alias declaration to put in a bashrc file.
# SublimeText auto-open project in current directory if it exists and argument is . or blank.
function project_aware_subl {
project_file=$(ls *.sublime-project 2>/dev/null | head -n 1)
if [[ ( ! -z "$project_file" ) && ( "${*}" == "." || -z "${*}") ]]
then
command subl "$project_file"
else
command subl ${*}
fi
}
alias subl="project_aware_subl"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment