Sublime Forum

Autoload .sublime-project

#1

I am wondering if it’s possible to autoload a project-name.sublime-project file if that file is located in the root directory of the opened source code.

I know I can do subl project-name.sublime-project but I would love to be lazier and just have to do subl .

I would guess that this is technically possible as other dot config files can be loaded by default too (e.g., .editorconfig).

If this is currently not possible, do you think this could be implemented in some future version? Like other dot files one could say IFF .sublime-project (without a filename) is found in the root directory of the source code it should be loaded automatically.

0 Likes

#2

This isn’t currently supported, but you might be interested in upvoting this issue and comment on the issue tracker:

1 Like

#3

FWIW, I use this function in my shell rc file to get something like this functionality:

subl() {
    SUBL=/usr/local/bin/subl
    owd=$(pwd)
    wd=$owd
    args=($@)

    if [ -d "${args: -1}" ]; then
        wd=$(realpath "${args: -1}")
    elif [ -s "${args: -1}" ]; then
        $SUBL $@
        return
    fi

    pushd $wd >/dev/null 2>&1
    setopt +o nomatch
    if [ -f *.sublime-project ]; then
        $SUBL ${args[@]:0:${#args[0]}-1} $(ls -1d *.sublime-project | head -n1)
    else
        $SUBL $@
    fi
    setopt -o nomatch

    if [ "$owd" != "$(pwd)" ]; then
        popd >/dev/null 2>&1
    fi
}

You can be even lazier with this: subl will open the first .sublime-project file in the current directory.

7 Likes

Workaround for SM to automatically open ST .sublime-project in root repo