iT邦幫忙

DAY 5
3

現代環境下的 Linux 裡的新工具系列 第 5

從單色進化到有色文字的工具:toilet

CLI常是單純的黑底白字或者白底黑字,要彩色就要有控制碼,竟然可以有banner的彩色版本。
先瀏覽一下toilet可以有什麼參數?因為此功能與banner或figlet類似,所以觀察後才去試那有關顏色功能。

$ toilet -h
  -f, --font <name>        select the font
  -d, --directory <dir>    specify font directory
  -s, -S, -k, -W, -o       render mode (default, force smushing,
                           kerning, full width, overlap)
  -w, --width <width>      set output width
  -t, --termwidth          adapt to terminal's width
  -F, --filter <filters>   apply one or several filters to the text
  -F, --filter list        list available filters
      --gay                rainbow filter (same as -F gay)
      --metal              metal filter (same as -F metal)
  -E, --export <format>    select export format
  -E, --export list        list available export formats
      --irc                output IRC colour codes (same as -E irc)
      --html               output an HTML document (same as -E html)
  -h, --help               display this help and exit
  -I, --infocode     print FIGlet-compatible infocode
  -v, --version            output version information and exit
Usage: toilet [ -hkostvSW ] [ -d fontdirectory ]
              [ -f fontfile ] [ -F filter ] [ -w outputwidth ]
              [ -I infocode ] [ -E format ] [ message ]

這toilet是類似banner, FIGlet可以寫大字,但再透過filter來把這些顯示做變化,先列出看有哪些filter:

$ toilet -F list
Available filters:
"crop": crop unused blanks
"gay": add a rainbow colour effect
"metal": add a metallic colour effect
"flip": flip horizontally
"flop": flip vertically
"180": rotate 180 degrees
"left": rotate 90 degrees counterclockwise
"right": rotate 90 degrees clockwise
"border": surround text with a border

會有彩色的filter是gay及metal來試一試:
如果用預設的字型,彩色會是這樣:

換了不同字型,覺得類似這樣子的字型,顏色比較明顯:

其實試了些字型,會發現有厚度的字,會讓整個顏色有實在感,不然顏色只有出現在邊邊的線上,看起來就比較單薄。

再看一看其他的filter會有什麼效果:
$ toilet -f mono9 ithelp -F border 可以加入邊框

$ toilet -f mono9 helo -F left 可向左旋轉90度

其他filter就不再例舉。另外也可以使用 FIGlet 的字型,可以輸出輸出的結果以html格式呈現。看了之前的例子,就不會太新奇了。


上一篇
從沒圖進化到有圖有字的工具:cowsay
下一篇
每日小格言 fortune
系列文
現代環境下的 Linux 裡的新工具27
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

我要留言

立即登入留言