Skip to content

Instantly share code, notes, and snippets.

@takikawa
Last active December 20, 2015 16:09
Show Gist options
  • Save takikawa/6159756 to your computer and use it in GitHub Desktop.
Save takikawa/6159756 to your computer and use it in GitHub Desktop.
;; goes in .racketrc
(define current-cow-flags (make-parameter ""))
(define old-print (current-print))
(define (print-with-cowsay val [port (current-output-port)])
(define output (with-output-to-string (thunk (old-print val))))
(when (not (string=? "" output))
(match-define
(list in _ _ _ _)
(process (format "cowsay ~a \"~a\"" (current-cow-flags) output)))
(display (port->string in) port)))
(current-print print-with-cowsay)
(define old-error-display-handler (error-display-handler))
(error-display-handler
(λ (string val)
(parameterize ([current-cow-flags "-f flaming-sheep"])
(print-with-cowsay string (current-error-port)))
(old-error-display-handler "" val)))
$ racket
Welcome to Racket v5.90.0.4.
-> (list 1 2 3)
___________
< '(1 2 3) >
-----------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
--> (/ 1 0)
______________________
< /: division by zero >
----------------------
\ . . .
\ . . . ` ,
\ .; . : .' : : : .
\ i..`: i` i.i.,i i .
\ `,--.|i |i|ii|ii|i:
UooU\.'@@@@@@`.||'
\__/(@@@@@@@@@@)'
(@@@@@@@@)
`YY~~~~YY'
|| ||
; [,bt for context]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment