How to modify or beautify a Linux terminal

Source: Internet
Author: User

Drop one first:

How to make your LD terminal more personal? First of all, we need to understand the following points of knowledge.
A: Configuration file

Personal configuration file:~/.BASHRC
Global settings file:/ETC/BASH.BASHRC (Modify requires Administrator privileges)

B
The command prompt is controlled by a special shell variable, namely: PS1,PS2,PS3,PS4.

We can only consider PS1. Execute at Terminal

What does the \n,\t,[in the output above mean? Here are some escape characters, which represent:

\a: Display time in 24-hour format (hh:mm)
\d: Represents a date in the format "Day of the Week"
\h: Displays the full host name
\h: Take the first name of the host only
\ n: Create a new row
\ t: Display time in 24-hour format, e.g., HH:MM:SS
\ t: Display time in 12-hour format
\u: Displays the account name of the current user
\v: Displays version information for BASH, such as 2.00
\v: Displays the version of Bash, including patch information, such as 2.00.0
\w: Displays the current working directory, unlike \w, which has a wavy number in front of the directory
\w: The full working directory name. The home folder is replaced by ~
\#: The first few commands issued
\$: Prompt character, general user is $, Administrator rights Display #
\[: non-printable character reference begins
\]: End of non-printable character reference
\ \: Back slash

How would you like to test your changes without modifying the original configuration file? We can enter the ps1= ' custom ' in the terminal, the return, can display the effect.

Here are some simple examples:

My own PS1.

Ps1= ' [\[\e[36;1m\]\[email protected]\h\[\e[31;1m\]\w\[\e[32;1m\]] ~\t\n> '

Default
12 PS1="\w:"#简单输出当前目录 PS1="\$:"#这个更简单

D
So how do you make it "color"?

The general set color format is:' \e[x;ym $PS 1 \e[m '

Explain:

\e[: Start color scheme settings
X;y: Color Pairing
\e[m End color scheme settings

Example: ps1= "\[\e[1;31m\] linuxdeepin"

More colors, such as:

How to modify or beautify a Linux terminal

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.