Prompt variable PS1
Example
export PS1="[\[\e[1;34;40m\]\u@\h\[\e[m\] \W]$ "
format description
- \d : # represents the date, the format is weekday month date, for example: "Mon Aug 1"
- \H : #full hostname
- \h : # only take the first name of the host
- \t : # Display time in 24-hour format, such as: HH:MM:SS
- \T : #Display time in 12 hour format
- \A : # Display time as 24 hours Format: HH:MM
- \u : #The account name of the current user
- \v : Version information of #BASH
- \w : # full working directory name
- \W : #Use basename to get the working directory name, so only the last directory will be listed
- \# : #The number of commands issued
- $ : # Prompt character, if it is root, the prompt is: #, for ordinary users: $
The format of the prompt color is: \e[font style; font color; background color m
The format of the end of the prompt color is: \e[0m
font style code
- 0 OFF
- 1 Highlight
- 2
- 3
- 4 underscore
- 5 flashes
- 6
- 7 Invert
- 8 not visible
The font style, font color, and background color are separated by semicolons in English half-width. All three are digital codes.
Some codes have no corresponding effect, which is the same as 0.
font | background | colour |
---|---|---|
30 | 40 | black |
31 | 41 | Red |
32 | 42 | green |
33 | 43 | yellow |
34 | 44 | blue |
35 | 45 | Fuchsia |
36 | 46 | cyan |
37 | 47 | White |