File: cdiff

package info (click to toggle)
ruby-term-ansicolor 1.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,104 kB
  • sloc: ruby: 1,269; makefile: 10
file content (19 lines) | stat: -rwxr-xr-x 314 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env ruby
#
## Little unix filter that colorizes diff output.
#

require 'term/ansicolor'

include Term::ANSIColor

ARGF.each do |line|
  STDOUT.print(
    case line
    when /^\+/ then green { line }
    when /^-/ then red { line }
    when /^(@@|diff)/ then blue { line }
    else line
    end
  )
end