Modify shell terminal prompt information

Source: Internet
Author: User

PS1: the user's usual prompt.
PS2: the first line is not complete. Wait for the prompt entered in the second line.

Public setting location:/etc/profile

Echo $ PS1 can see the current prompt settings
For example, Green is displayed and time and shell version are added.
Export PS1 = "\ [\ e [32m \] [\ U @ 'you are right' \ W \ t \ v \ D] \ $"
Or
PS1 = "\ [\ e [32m \] [\ U @ 'you are right' \ W \ t \ v \ D] \ $"


Or

 

Export PS1 = "\ [\ e [31m \] [\ U @ \ H \ W] \$ {? #0 }#\ [\ e [0m \]"

 

[Root @ WWW ~] # Echo $ PS1
[\ U @ \ H \ W] \ $

after restarting, you only need to modify the configuration file.
for the current user, you only need to modify ~ /. Bashrc, for all users in the system, modify/etc/bashrc
ps1 = "\ [\ e [32m \] [\ U @ \ H \ W \ t \ v \ D] \ \ $ "
export PS1

the default special symbol in Shell environment:
\ D: represents the date, in the format of weekday month date, for example:" Su N sep 18 "
\ H: The complete host name. For example, my machine name is RedHat. in Linux, the name is fc4.linux
\ H: only the first name of the host. In the preceding example, the name is RedHat. linux ,. linux is omitted
\ t: The display time is in the 24-hour format, for example, HH: mm: SS
\ t: display time: 12 hours format
\ A: display time: 24 hours format: hh: mm
\ U: Account name of the current user
\ V: bash version
\ W: complete working directory name. In the home directory ~ Replace
\ W: Use basename to get the working directory name, so only the last directory is listed
\#: the commands issued
\$: prompt character. If it is root, the prompt is: #, and the normal user is: $
\ n: Line Break

font or background color modification:
In ps1, set the Character Sequence color format to \ [\ e [F; BM \]
where ''f'' is the font color, 30-30 ~ 37; ''B 'indicates the background color, numbered 40 ~ 47
you can use ''\ e [0m'' to disable color output. When B is set to 1, highlighted and bold text is displayed.

Color correspondence:
30 40 black
31 41 colors
32 42 colors
33 43 colors
34 44 colors
35 45 Violet colors
36 46 green colors
37 47 white
CodeMeaning:
0 off
1 highlighted
4 underline
5 flashes
7. Reverse display
8 invisible

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.