Created
February 19, 2011 20:33
-
-
Save jbpotonnier/835343 to your computer and use it in GitHub Desktop.
Colorize unified diff output
This file contains hidden or 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
(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