From b0a14e013b318fa87714414b8ece95780527bddf Mon Sep 17 00:00:00 2001 From: Nathan Lasseter Date: Fri, 18 Sep 2015 11:51:28 +0100 Subject: Initial commit --- equote | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 equote (limited to 'equote') diff --git a/equote b/equote new file mode 100755 index 0000000..3aadaed --- /dev/null +++ b/equote @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby + +LINELENGTH = (ARGV.shift || 72).to_i + +lines = $stdin.readlines + +lines = lines.map { |line| + if line.length > (LINELENGTH-2) then + newlines = [] + while line.length > (LINELENGTH-2) do + i = LINELENGTH-2 + while line[i] != " " do + i -= 1 + end + newlines << line[0...i] + line = line[i..-1] + end + newlines << line + newlines + else + line + end +} + +lines = lines.flatten + +lines = lines.map { |line| + "> #{line}" +} + +puts lines -- cgit v1.2.1