add this to your ~/.gitconfig
:
sublp = "!f() {\nSUBL=/usr/local/bin/subl\nowd=$(pwd)\nwd=$owd\nargs=($@)\nif [ -d \"${args: -1}\" ]; then\nwd=$(realpath \"${args: -1}\")\nelif [ -s \"${args: -1}\" ]; then\n$SUBL $@\nreturn\nfi\npushd $wd >/dev/null 2>&1\nsetopt +o nomatch\nif [ -f *.sublime-project ]; then\n$SUBL ${args[@]:0:${#args[0]}-1} $(ls -1d *.sublime-project | head -n1)\nelse\n$SUBL $@\nfi\nsetopt -o nomatch\nif [ \"$owd\" != \"$(pwd)\" ]; then\npopd >/dev/null 2>&1\nfi\n}; f"
Then in SM’s Default.sublime-commands
:
[
{
"caption": "Open project in Sublime Text",
"command": "git",
"args": {"argv": ["sublp"]}
},
]
I’ve got the inspiration from aliasing terminal command in Discord forum. And the script from @ig0774 to autoload Sublime Project in root: