Article Title: how to set the terminal prompt in Linux. Linux is a technology channel of the IT lab in China. The features of basic classification terminal prompts including desktop applications, Linux system management, kernel research, embedded systems, and open source 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' ]; thenexport PS1="[\[\e[36;1m\]\u@\h \[\e[31;1m\]\w\[\e[32;1m\]]> "zhcon --utf8clearelif [ $TERM = "xterm" ]; thenexport PS1="[\[\e[31;1m\]\w\e[0m]> "fi-------------------
|