Last active
December 20, 2015 13:59
-
-
Save jrob00/6143229 to your computer and use it in GitHub Desktop.
User profile extension that allows you to execute "subl" in a project's root folder and have it automatically open the project file if such a file exists. This script looks in the current directory and in a hard coded location in case that's where you store all your project files.
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
# sublime text alias | |
function project_aware_subl() { | |
current_directory=${PWD##*/} | |
result=$(ls *.sublime-project 2>/dev/null | head -n 1) | |
if [ -z $result ]; then | |
result=$(ls ~/Documents/Sublime/${current_directory}.sublime-project 2>/dev/null | head -n 1) | |
result=$(printf '%q' "$result") | |
if [[ $result == "''" ]]; then | |
unset result | |
else | |
echo "opening project.." | |
fi | |
else | |
echo "opening project.." | |
fi | |
subl ${*:-${result:-.}} | |
} | |
alias subl="project_aware_subl" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script requires that the subl sym link already exists: