Bruno Carlin

Automatically open Sublime Text projects in a directory

I usually start Sublime Text 2 from the command line to work, depending on the case, on the content of a directory or on a project (materialized with a *.sublime-project file).

It ends up with one of the following commands :

Here is the snippet I added to my .bashrc file to have the subl command automatically “guess” what I want. It does the following:

function project_aware_subl {
  project_file=$(ls *.sublime-project 2>/dev/null | head -n 1)
  subl ${*:-${project_file:-.}}
alias subl="project_aware_subl"