Ubuntu Terminal Color Configuration

Source: Internet
Author: User
Tags transparent color

For the students who have just touched Ubuntu, open the terminal (CTRL+ALT+T), will find that there is a color, whether it is the user name, hostname or command is white, of course, with LS to list the file is more than one color. Even so, it's not efficient for developers, because sometimes you need to go to dozens of lines or even hundreds of lines of code to find the commands you've run or the information you want. Therefore, it is very important to color the terminal (Terminal).

1, first in the terminal with Gedit open configuration file (~/.BASHRC), such as:

$ gedit ~/.BASHRC

2. Add the following code at the end:

ps1=‘${debian_chroot:+ ($debian _chroot)}\[\033[01;< Span class= "number" >35; 40m\]\u\[\033[00; 00; 40m\]@\[\033[01; 35; 40m\]\h\[\033[00; 31; 40m\]:\[\033[00; 00; 40m\]\w \[\033[01; 32; 40m\]\$ \[\033[01; 36; 40m\] '              

After you enter this code at the end of the current file in the Open editor, press Ctrl+s to save it. You can then close the editor directly by closing the editor, or you can press CTRL + C in the terminal to close the compiler and continue executing the command (note that you can continue the command only if you close the editor).

3, restart the terminal, you can see your color.

The following is the process of color matching:

Foreground background color

30 40 Black

31 41 Red

32 42 Green

33 43 Yellow

34 44 Blue

35 45 Purple Red

36 46 Blue

37 47 White

1 Transparent Color

Code meaning

0 OFF

1 highlighting

4 Underline

5 Flashing

7 Anti-white display

8 Not visible

In the case of color mode open, the PS1 variable represents the user name + hostname + pathname (long path) + $

ps1='${debian_chroot:+ ($debian _chroot)}\[email protected]\h:\w\$ ' 

Next, we need to set the font color of the displayed information, first look at how the color is set:

A separate color setting: \ 033[code; foreground; background m, such as: \[\ 033[1;32;40m\] indicates that the highlighted font is green and the background color is black.

Note: The color settings are placed in front of the corresponding settings, such as user name color settings: \[\033[01;35;40m\]\u

The following is attached, not my terminal color settings:

ps1=‘${debian_chroot:+ ($debian _chroot)}\[\033[01; 35; 40m\]\u\[\033[00; 00; 40m\]@\[\033[01; 35; 40m\]\h\[\033[00; 31; 40m\]:\[\033[00; 00; 40m\]\w \[\033[01; 32; 40m\]\$ \[\033[01; 36; 40m\] ' 

go from: http://www.tuicool.com/articles/NRZfIj

Ubuntu Terminal Color Configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.