Skip to content

Instantly share code, notes, and snippets.

@mjsteinbaugh
Created February 1, 2018 21:50
Show Gist options
  • Save mjsteinbaugh/bc50be6972c6422a30278e446dc3e61a to your computer and use it in GitHub Desktop.
Save mjsteinbaugh/bc50be6972c6422a30278e446dc3e61a to your computer and use it in GitHub Desktop.
BBEdit Reverse Lines Text Filter
#!/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