TIPS: how to set a Linux terminal prompt

Source: Internet
Author: User
Tags printable characters
Linux terminal prompt features are defined by the system environment variable ps1. Run the ''echo $ PS1 #39; #39; command to view the current settings. PS1 values are composed of a series of static text or

Linux terminal prompt features are defined by the system environment variable ps1. Run the ''echo $ PS1 #39; #39; command to view the current settings. The PS1 value is composed of a series of static text or \ and

Linux terminal prompt features are defined by the system environment variable ps1. Run ''echo $ ps1' to view the current settings.

The PS1 value is composed of a series of static texts or \ and escape character sequences, such:
PS1 = "\ u @ \ H \ w $"

Useful escape sequences include:
\ E ASCII Escape Character
\ H Host Name
\ H complete host name
\ L terminal device name
\ T in 24-hour format
\ T 12-hour time
\ U User Name
\ W current working directory (absolute path)
\ W current working directory (basename)
\! Location of the current command in the History buffer zone
\ $ If the current user is a super user, insert the character #; otherwise, insert the character $
\ [Appear before the Character Sequence without moving the cursor
\] Appears after non-printable characters

It is annoying to always face the black and white screen. We can set the PS1 variable to make the prompt a color. In PS1, set the Character Sequence color format:

\ [\ E [F; Bm \]
''F'' indicates the font color, ranging from 30 to 30 ~ 37; ''B 'indicates the background color, numbered 40 ~ 47.
You can use ''\ e [0m'' to disable color output. In particular, when B is set to 1, bold text is highlighted.

I think this is enough. It's time to customize it. Now post my settings:

If [$ TERM = 'linux ']; then
Export PS1 = "[\ [\ e [36; 1m \] \ u @ \ h \ [\ e [31; 1m \] \ w \ [\ e [32; 1 MB \]>"
Zhcon -- utf8
Clear
Elif [$ TERM = "xterm"]; then
Export PS1 = "[\ [\ e [31; 1m \] \ w \ e [0 m]>"
Fi
-------------------



-------------------
Meng Hu

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.