Skip to content

Instantly share code, notes, and snippets.

@bengourley
Created April 7, 2011 16:03
Show Gist options
  • Save bengourley/908081 to your computer and use it in GitHub Desktop.
Save bengourley/908081 to your computer and use it in GitHub Desktop.
// Initialise vars
var gitOutput = "",
branch = null;
// Start reading stdin
process.stdin.resume();
// Store read in chunks
process.stdin.on('data', function (chunk) {
gitOutput += chunk;
});
// Finished reading in git output
process.stdin.on('end', function () {
branch = gitOutput.split(" ").pop().split("/").pop();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment