Basic Werk | Memo | Contact


MEMOMEM

Gauche_print_with_color_on_Terminal



Mac の Terminal 上で文字に色付けして表示させるためのマクロ。

最後、文末でデフォルトの文字色(\x1b[0m)に常に戻してあげるのがコツ。



(define-syntax printc (syntax-rules () [(printc clr args ...) (let ((colors '((red . "\x1b[31m") (pink . "\x1b[35m") (purple . "\x1b[35m") (blue . "\x1b[34m") (green . "\x1b[32m") (water . "\x1b[36m") (yellow . "\x1b[33m") (dim . "\x1b[2m") (blight . "\x1b[1m") (u . "\x1b[4m") (rev . "\x1b[7m") (off . "\x1b[0m")))) (print (cdr (assoc clr colors)) args ... (cdr (assoc 'off colors))))]))


#Gauche #gosh #Shell #Mac



SN 2013/06/26 23:23:04

Archives > Gauche_print_with_color_on_Terminal.html







MEMOMEM



More Contents

Basic Werk | Previous Blog

仕事と日 | 中村 心