การปรับแต่งสีตัวอักษร บนเทอมินัล และพื้นหลังบนเทอมินัล

เปิด Terminal ขึ้นมา Alt+Ctrl+T

Type : “gedit .bashrc”


$ gedit .bashrc
พิมพ์
export PS1="\e[0;31m[\u@\h \W]\$ \e[m"

ไว้ท้ายสุด

Save and close the file.

แล้วตรวจสอบด้วยการเปิด Terminal อีกครั้งนึง

tput command

You can also use tput command. For example display RED prompt use tput as follows:
export PS1="\[$(tput setaf 1)\]\u@\h:\w $ \[$(tput sgr0)\]"

handy tput commands

  • tput bold – Bold effect
  • tput rev – Display inverse colors
  • tput sgr0 – Reset everything
  • tput setaf {CODE}- Set foreground color, see color {CODE} below
  • tput setab {CODE}- Set background color, see color {CODE} below

Colors {code} code for tput command

Color {code} Color
0 Black
1 Red
2 Green
3 Yellow
4 Blue
5 Magenta
6 Cyan
7 White

ผลลัพธ์ ที่ได้  ปรับให้คล้าย กับ Mint12 Terminal จะได้เป็น

credit: http://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/

1 ตอบกลับที่ การปรับแต่งสีตัวอักษร บนเทอมินัล และพื้นหลังบนเทอมินัล

  1. namkangwarn พูดว่า:

    echo ” ______________________________________
    / Hey come back to me, NaMkAnGwArN \\
    \ Don’t you love me any more..? /
    ————————————-
    \\
    \\
    ___
    {~._.~}
    ( Y )
    ()~*~()
    (_)-(_)


    export PS1=”\[$(tput setaf 2)\]\[$(tput bold)\]\u@\h \[$(tput setaf 4)\]\w$ \[$(tput sgr0)\]“

ใส่ความเห็น

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Connecting to %s

Follow

Get every new post delivered to your Inbox.