2011/03/25

echo 改變顏色

echo $PATH | grep '4.2.2' > /dev/null
if [ $? = 0 ]; then
    echo -e "目前編譯環境為\033[32m[gcc 4.2.2]\033[0m"
fi

echo -e "\033[??m"
??為ANSI 顏色碼,從 man 查來的 → man 5 dir_colors
          0     to restore default color
          1     for brighter colors
          4     for underlined text
          5     for flashing text
         30     for black foreground
         31     for red foreground
         32     for green foreground
         33     for yellow (or brown) foreground
         34     for blue foreground
         35     for purple foreground
         36     for cyan foreground
         37     for white (or gray) foreground
         40     for black background
         41     for red background
         42     for green background
         43     for yellow (or brown) background
         44     for blue background
         45     for purple background
         46     for cyan background
         47     for white (or gray) background
前景背景可以一起使用,用分號隔開 Ex:echo -e "33[41;32m"

沒有留言: