Skip to content

Instantly share code, notes, and snippets.

@cyjake
Last active August 29, 2015 14:02
Show Gist options
  • Save cyjake/72a9f4ab8cffd026b7b3 to your computer and use it in GitHub Desktop.
Save cyjake/72a9f4ab8cffd026b7b3 to your computer and use it in GitHub Desktop.
Simple subl wrap that is project configuration aware
#!/usr/bin/env node
'use strict';
/* jshint asi: true */
var fs = require('fs')
var path = require('path')
var spawn = require('child_process').spawn
fs.readdir(process.cwd(), function(err, entries) {
var project
for (var i = 0; i < entries.length; i++) {
var entry = entries[i]
if (path.extname(entry) == '.sublime-project') {
project = entry
}
}
spawn('subl', project ? ['--project', project] : ['.'])
})
// 1. Create a new file in one of your PATH folders
// 2. Name it whatever you prefer
// 3. $ chmod a+x <file_name>
//
// When you execute it in some of your sublime text project folders,
// it will detect .sublime-project file if there's any and open
// that project with command like `subl --project foo.sublime-project`.
//
// Should be simpler if I can write this in Bash Script though.
@yisibl
Copy link

yisibl commented Jun 5, 2014

顶一行帝!

@nuysoft
Copy link

nuysoft commented Jun 5, 2014

1w 个赞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment