It's fun for the terminal print in the shell!First know that the end of the shell print has echo printf is commonly used is echo slightly;
Note: Font Color reset = 0, black = 30, red = 31, green = 32, ***=33, blue = 34, magenta =35, cyan = 36, white =37.Background color reset = 0, black = 40, red = 41, green = 42, ***
There are several prompt variables to mention when the color of the terminal is mentioned under the shell:
PS1: The default prompt, that is, after the remote boarding system, open the terminal, we see the familiar prompt every day;
[Root@vps ~] $echo $PS 1[\u@\h \w]$
PS2: It is our command line to write the "\" on our command line, and the one that is displayed on the other line;
[Root@vps ~] $echo "Hel
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
Document directory
Task: display current bash prompt (PS1)
Task: modify current bash prompt
Task: add colors to the prompt
Task: how to make the prompt setting permanent
Tput command
Handy tput commands
Colors {code} code for tput command
Q. How do I change the color of my shell prompt under Linux?
A. YouCan change the color of your
The echo display in the shell script is displayed in color with the echo displayed in color with the parameter-EThe format is as follows:
Copy Code code as follows:
Echo-e "\033[character background color; text color m string \033[0m"
For example:
Shell script programming (strict terminal format control, beautiful output font color), shell script Programming
#! /Bin/bash # font output color and terminal format control # font color 30-37echo-e "\ 033 [30 m black character \ 033 [0 m" echo-e "\ 033 [31 m red word \ 033
The color of the text terminal can be generated using the ANSI non-normal character sequence. Example:
Echo-e "\033[44;37;5m ME \033[0m Cool"
The above command sets the background to blue, the foreground is white, the blinking cursor, the output character "ME", and then reset the screen to the default settings, the output character "cool". "E" is an optional option for command Echo, which activates the parser for special characters. "\033" boots a seq
Implementation code:
#!/bin/sh
# ANSI Color-Use this variables to make output in different colors
# and formats. Color names that end with the ' F ' are foreground (text) colors, # and those ending with
' B ' are background.
Initializeansi ()
{
esc= "\033" # if this doesn ' t work, enter an ESC directly
blackf= ' ${esc}[30m '; Redf= "${esc}[31m"; greenf= "${esc}[32m"
yellowf= "${esc}[33m" b
BASH shell set font and background color
Echo-e "\e[31mtest\e[41m"
\e[30m change the display color of a character to black
\e[31m change the display color of a character to red
\e[32m change the display color of a character to green
\e[33m change the display
Objective
We all know that when you use the LS command to list file lists, different file types are displayed in different colors. So how do you implement this color-colored text output? The answer is not complicated, whether it's in the shell or the C language.
First, the implementation of the shell under the method
First, under the
Bash's color display rules:ASCII encoding is set for color:\033:ctrl Key[: Control the spacing character between character and color code0m: command to turn off color properties;1m: Bold for display text characters4m: Multibyte underline for text word5m: Make text characters blink7m: Exchange the background and foregro
Set font and background color under BASH shell\e[30m change the display color of a character to black\e[31m change the display color of a character to red\e[32m change the display color of a character to green\e[33m change the display co
Output colored text in the shell using the echo commandNameecho-Displays a line of textProfileecho [Options] ... [String] ...DescribeOutputs a string to the standard output.-N does not output line breaks-E Open backslash ESC escape-e Suppress backslash ESC escape (default)--HELP Display Help--version Display versionNote You must have the-e option for the output color.And then say the point: ANSI control code is used in the output of
We know that when you use the ls command to list files, different file types are displayed in different colors. How can we achieve this color-based text output? The answer is not complex, whether using shell or C language.
I. Implementation Method in shell
First, let's talk about how to implement it in shell. You can u
In the shell script, ECHO Displays the content in color, and ECHO Displays the content in color. You need to use the-e parameter.The format is as follows:Echo-e "\ 033 [background color; text color M string \ 033 [0 m"For example:Echo-e "\ 033 [41; 36 m something here \ 033
Let's give your shell a bit of color. to avoid setting for every user, directly modify the/etc/profile File 1. add three lines in Linux: Give your ls a color [html] aliasls amp; #39;/bin/ls -- colorauto amp; #39; give your grep a color [html] aliasgrep amp ;... let's give your s
Shell terminal character color settings
When writing a program, the terminal usually needs to display various colors such as red or green on the output, so that users can be notified more clearly. The following is how to set the terminal color of the Shell system:
The Character Col
Objective
Everyone knows that when using the LS command to list file lists, different file types are displayed in different colors. So how do you implement such a colored text output? The answer is not complicated, either in the shell or the C language.
First, the implementation method under the shell
First of all, under the shell, how to achieve. This can be ac
Here is a record of how the shell script can be color-output, using a bit in Python also applies.echo Display in shell script with color display, echo display with color, need to use parameter-EThe format is as follows:Echo-e "\033[word background
When writing a shell script. By changing the shell's display color, you can not only change the experience of using the shell terminal, but also more useful, you can distinguish the normal output by changing the color of the display content. Output from different levels of attention, such as warning and error.1. Escape
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.