Skip to content

Instantly share code, notes, and snippets.

@jbpotonnier
Created February 19, 2011 20:33
Show Gist options
  • Save jbpotonnier/835343 to your computer and use it in GitHub Desktop.
Save jbpotonnier/835343 to your computer and use it in GitHub Desktop.
Colorize unified diff output
(require-extension ansi-escape-sequences)
(require-extension srfi-13)
(require-extension extras)
(define (colorize txt)
(set-text
(cond
((string-prefix? "---" txt) '(bold))
((string-prefix? "+++" txt) '(bold))
((string-prefix? "-" txt) '(fg-red ))
((string-prefix? "+" txt) '(fg-green))
((string-prefix? "@@" txt) '(fg-cyan))
(else '()))
txt))
(define (colorize-lines)
(let ((l (read-line)))
(if (not (eof-object? l))
(begin ((compose print colorize) l)
(colorize-lines)))))
(colorize-lines)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment