Created
February 1, 2018 21:50
-
-
Save mjsteinbaugh/bc50be6972c6422a30278e446dc3e61a to your computer and use it in GitHub Desktop.
BBEdit Reverse Lines Text Filter
This file contains 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/local/bin/node | |
// Michael Steinbaugh | |
// 2018-02-01 | |
// | |
// This script requires node | |
// brew install node | |
// | |
// Copied from Steven Schobert | |
// https://github.com/stevenschobert/dotfiles/blob/master/.bbedit/Text%20Filters/.reverse_lines.js | |
var eol = require('os').EOL; | |
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
var newLines = []; | |
process.stdin.on('data', function(chunk) { | |
var strings = chunk.toString(); | |
var lines = strings.split(eol); | |
lines.forEach(function(line) { | |
newLines.unshift(line); | |
}); | |
}); | |
process.stdin.on('end', function() { | |
process.stdout.write(newLines.join(eol)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment