Skip to content

Instantly share code, notes, and snippets.

@cades
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cades/9021409 to your computer and use it in GitHub Desktop.
Save cades/9021409 to your computer and use it in GitHub Desktop.
把 lisp-koan 的輸出加上顏色
#!/bin/bash
sbcl --script contemplate.lsp | tail -n 13 \
| sed "s/INCOMPLETE/`tput setaf 6`INCOMPLETE`tput sgr0`/g" \
| sed "s/FAIL/`tput setaf 1`FAIL`tput sgr0`/g" \
| sed "s/PASS/`tput setaf 2`PASS`tput sgr0`/g"
# 未完成=青色
# 失敗=紅色
# 通過=綠色
# 關於色碼控制, 這次的成果是用tput的解法
# 參考 http://en.wikipedia.org/wiki/Tput
# 關於sed, 用單引號'或雙引號"夾住指令, 似乎有很大的差別喔.
@cades
Copy link
Author

cades commented Mar 1, 2014

行末的backslash後面不能接註解, 因為那是跳脫換行字元用的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment