PS1 prompts explain

  
 

Note: How to use: # PS1='Custom content' Note the single quotes on both sides Example: PS1='(\\u@\\H \\d \\t)\\$' PS1: This is the user's usual prompt. PS2: The first line has not been lost, waiting for the prompt entered in the second line. The Linux system prompt is defined by the system variable PS1. The default form of the general system is: [username@host working directory]$. Use the echo $PS1 to get the value of PS1, that is, PS1="[\\u@\\h \\w]"\\$ You can change the PS1 after logging in. Display style, but when you exit the restart login and enter the system, the style becomes the default style of the system. If you want to change its style completely, you can only change it from the configuration file. PS is defined in the .bash_profile in the user root directory. Such as # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs #The following is the value of the set PS1 PS1="[\\u @\\h \\w]\\$" PATH=$PATH:$HOME/bin #Use export to output PS1 so that it can be used in the subshell, which will cause ROOT users to also use this style #export PS1 Use export PATH unset USERNAME The following is a brief description of the meaning of the default special symbol in the environment: \\d : represents the date, the format is weekday month date, for example: "Mon Aug 1" \\H : The full host name. For example: my machine name is: fc4.linux, then the name is fc4.linux \\h: only the first name of the host, for example, fc4, .linux is omitted \\t: display time is 24 Hour format, such as: HH:MM:SS \\T : Display time is 12 hours format\\A : Display time is 24 hours Format: HH:MM \\u : Current user's account name\\v : BASH version information\\w : The full working directory name. The home directory will replace \\W with ~: use the basename to get the working directory name, so only the last directory \\# : the first command issued by the \\$ : prompt character, if it is root, the prompt is: # , Ordinary users are: $

We can make the prompt color by setting the PS1 variable. The format of the character sequence color set in PS1 is: \\[\\e[F;Bm\\] where ``F'' is the font color, number 30~37; ``B'' is the background color, number 40~47. The color output can be turned off by ``\\e[0m''; in particular, when B is 1, the bolded bold text will be displayed. For details, please see the color table and code table below. Color table foreground background color 30 40 black 31 41 red

Copyright © Windows knowledge All Rights Reserved