Last active
July 12, 2019 17:23
-
-
Save bcarlin/5318397 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.
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
# [...] | |
function project_aware_subl { | |
project_file=$(ls *.sublime-project 2>/dev/null | head -n 1) | |
command subl ${*:-${project_file:-.}} | |
} | |
alias subl="project_aware_subl" | |
# [...] |
Glad it helped you!
I never ran into this issue (also, I'm not using {ba,z}sh for several years now) and I didn't know about command
.
I've updated the gist. Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is such a great concept! I ran into the same exact problem -- I have a project config I always want to use, since it has folder excludes and everything, and it's in the same folder as my actual project; but I always forget to open it because I just use
subl .
habitually.This almost worked for me. I ran into a weird recursion if I sourced the profile more than once (since subl is already a function defined as itself). Using the
command
command bypasses functions for that and resolved. Here's what I ended up with, also expanding the logic to be more readable for myself, if it helps anyone who lands on this in the future.