Ubuntu Modify terminal display host name, user name, directory different colors

Source: Internet
Author: User
Tags set background

Open Terminal input: Echo $PS 1

Input:gedit ~/.BASHRC

#定位到如下代码:if["$color _prompt"=Yes]; Then PS1='${debian_chroot:+ ($debian _chroot)}\[\033[01;32m\]\[email protected]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[ 00m\]\$'ElsePS1='${debian_chroot:+ ($debian _chroot)}\[email protected]\h:\w\$'fi #注释掉改为: #if["$color _prompt"=Yes]; then# PS1='${debian_chroot:+ ($debian _chroot)}\[\033[01;32m\]\[email protected]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[ 00m\]\$'# Else# PS1='${debian_chroot:+ ($debian _chroot)}\[email protected]\h:\w\$'# fi

and add the following line of code at the end of the text

#customer:P S1="#root:P S1="

Exit after saving, and then source

Toggle root permissions, inthe root directory /root also operate again  Effects such as

The middle host name can also be modified, referring to the meaning of the default special symbol

If you want to set to another color, refer to the following font color codes

The interface control format is as follows: printf ("\033[word background color; font Color m string \033[0m"  ); Example: printf ("\033[1m\033[45;33m hello_world \033[0m\n");  Color code:  Word background Color: 40--49                     Font Color: 30-39               40:  Black                              30:  Black                   41 :  Red                              31:  Red                   42:  Green                               32:  Green                   43:  Yellow                              33:  Yellow                   44:  Blue                               34:  Blue                  45:  Violet                              35 :  Violet                    46:   Dark green                         36:  dark green   &NBSP ;              47:  White                &NB       Sp        37:  white ANSI control code:\033[0m    close all Properties        \033[1m    setting High brightness       \033[4m    underline        \033[5m    flashing       \033[7m     Anti-display       \033[8m    blanking    \033[30m   - -   \033[37m    Setting foreground color      \033[40m   --    \033[47m    Set Background color       \033[na    cursor up n rows      \03[nB    cursor down n rows        \033[nC    cursor Right shift n rows      \033[nD    cursor shift left N rows   PS: The meaning that the default special symbol represents:
\d: Represents the date, formatted as weekday month date, for example: "Mon-1"
\h: The full host name. For example: My machine name is: Fc4.linux, then this name is Fc4.linux
\h: Only the first name of the host is taken, as in the example above, then Fc4,.linux is omitted
\ t: Display time in 24-hour format such as: HH:MM:SS
\ t: Display time in 12-hour format
\a: Display time in 24-hour format: hh:mm
\u: Current user's account name
Version information for \v:bash
\w: The full working directory name. Home directory will be replaced by ~
\w: Use basename to get the working directory name, so only the last directory is listed
\#: The first few commands issued
\$: Prompt character, if root, Prompt is: #, normal user is: $

Ubuntu Modify terminal display host name, user name, directory different colors

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.