Change the PS1 color and display the adjusted text color in shell.

Source: Internet
Author: User

The color code is basically clipped between "\ e [" and "m": \ e [32; 1 m

 

You can use \ e [0 m to disable color output. In particular, when B is set to 1, the highlighted and bold text is displayed.

Common color codes:

 

Foreground background color

--------------- 30 40 black 31 41 red 32 42 green 33 43 yellow 34 44 blue 35 45 purple 36 46 cyan 37 47 white

 

Code meaning

---------------- 0 OFF1 highlighted 4 underline5 flashing 7 reversed white display 8 invisible

 

 

Change the color of the prompt in ps1.

# Set PS1
PS1 = "\ u @ \ H \ e [32; 1 m [\ w] \ e [0 m \ $"

 

Change color in shell

#! /Bin/bash
#===================================================== ========================
# Text color change test
#===================================================== ========================
Echo "Pay attention to the current text color"
Echo-e "\ e [31; 42 m"
Echo "Pay attention to the current color"
Echo-e "\ e [0 m"
Echo "Restore text color"

 

 

 

 

Related Article

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.