-
-
Save cyjake/72a9f4ab8cffd026b7b3 to your computer and use it in GitHub Desktop.
Simple subl wrap that is project configuration aware
This file contains hidden or 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
#!/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. |
顶一行帝!
1w 个赞
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very simple, just put this code to your login script, .zshrc or .bashrc etc.