Ubuntu9.04 set the SHELL prompt attribute PS1 = "[\ e [32; 1m \ u @ \ h \ W] \ $" // the general format PS1 is an environment variable, it is called a prompt variable. It is case sensitive and followed by the number "1", not the letter "I" \ e [32; 1 m: this is the escape character that controls the font and background color, 30 ~ 37 is the font color, 40 ~ 47 is the 32; 1 M number in the background color example.
Set SHELL prompt attributes in Ubuntu 9.04
PS1 = "[\ e [32; 1m \ u @ \ h \ W] \ $" // General Format
PS1: an environment variable. It is called a prompt variable. It is case sensitive and followed by the number "1", not the letter "I"
\ E [32; 1 m: This is the escape character that controls the font and background color, 30 ~ 37 is the font color, 40 ~ 47 is the background color
In the example, the 32; 1 m digit position can be reversed, for example, \ e [1; 32 m. If it is in the X environment, you can change the range of 1 to 0 ~ 10, some useless places: 0 or do not write (\ e [0; 32 m or \ e [; 32 m) Show light color, 1: Show highlighted 4: underline ..... if the effect is not good but cannot be restored, do not write the number before m, for example, \ e [32; m, or log out directly before logging in.
\ U \ h \ W: Some escape characters, which are explained in detail below:
\ D: represents the date, in the format of weekday month date, for example: "Mon Aug 1"
\ H: complete host name. For example, if my machine name is fc4.linux, this name is fc4.linux.
\ H: only the first name of the host. In the preceding example, the name is fc4, and the name of. linux is omitted.
\ T: The display time is in the 24-hour format, for example, HH: MM: SS.
\ T: The display time is in the 12-hour format.
\ A: The display time is in the 24-hour format: HH: MM.
\ U: Account name of the current user
\ V: BASH version information
\ W: complete working directory name. In the home directory ~ Replace
\ W: Use basename to get the working directory name. Therefore, only the last directory is listed.
#: Commands issued
\ $: The prompt character. If it is root, the prompt is: #, and the normal user is: $
\ N: Creates a new row.
The font is not limited to one color. It can have multiple colors:
PS1 = "[\ e [32; 1 m \ u @ \ e [35; 1 m \ h \ e [31; 1 m \ W] \ $"
The preceding two Commands will expire after logging out. Use the following method to make them permanently effective:
# Vi/etc/profile
In "export PATH ....." Add the line below:
Export PS1 = "[\ e [32; 1 m \ u @ \ h \ W] \ $"
------------------------------------------------------------------
My operations are as follows:
The actual instruction and actual input are in red.
------------------------------------------------------------------
Run the following command in the root directory:
Liyingxuan @ mvp :~ $ Vi. bashrc // edit the file
Add the following at the end of the file:
PS1 = "\ [\ e [34; 34 \] \ h \ [\ e [00m \]: \ w \ $" // mainly sets the Blue Host Name and does not display the user name
Save and exit!
Liyingxuan @ mvp :~ $ Source ~ //. Bashrc // make the file take effect immediately
Mvp :~ $ Ls
Mvp :~ $ Ls