Linux Shell command prompt and modify colors

Step:
View
[root @ localhost ~] $ cat ~ / .bashrc
edit
[root @ localhost ~] $ vim ~ / .bashrc

Demo:
[root @ localhost ~] $ cat ~ / .bashrc
# .bashrc
# and the User specific aliases Functions
Alias RM = 'RM -i'
Alias = CP 'CP -i'
Alias Music Videos = 'Music Videos -i'

# Add to this line (effect: [root @ localhost ~] - > red @ yellow and blue)
PS1 = "\ n \ [\ e [ 37; 1m [\] \ [\ e [31; 1m \] \ u \ [\ e [39; 1m \] @ \ [\ e [33; 1m \] \ H \ [\ E [34 is; 1M \] \ W \ [\ E [37 [; 1M \]] \ n-\ [\ E [32; 1M \] \ $ \ [\ E [0m \] "
# the Source Global Definitions
IF [-f / etc / bashrc]; the then
. / etc / bashrc
fi

next reload ~ / .bashrc to take effect:
[root @ localhost ~] $ Source ~ / .bashrc




description:
1. Linux login process to load configuration file order:
/ etc / profile → /etc/profile.d/*.sh → ~ / .bash_profile → ~ / .bashrc → [/ etc / bashrc]
can view the default ~ / .bashrc file as follows:
[the root @ localhost ~] $ ~ CAT / .bashrc
# .bashrc

# specific aliases and the User Functions

# Global Definitions the Source
IF [-f / etc / bashrc]; the then
/ etc / bashrc.
Fi
2. Shell command prompt and color is configured by PS1:
. 1 [the root @ localhost ~] $ echo $ PS1
2 \ [\ E [32; 40m \] [\ U @ \ H \ W is] $ \ E [m

wherein PS1 common parameters are as follows:
\ D: # represents the date, format weekday month date, for example: "Mon-Aug. 1"
\ H: # full host name
\ h: # take only the first host name
\ t: # a 24-hour display time format, such as: HH: MM: SS
\ T: # display for 12-hour format
\ a: # show time is 24 hour format: HH: MM
\ U: # current user account name
\ v: version information #BASH of
\ w: # complete working directory name
\ W: # use basename get working directory name, it lists only the last directory
\ #: # The first several commands issued
\ $: # prompt character, if a root, the prompt is: #, then the average user is: $

3. setting the color value
set in the character color PS1 format: \ [\ e [F; Bm \], where "F" is a font color, No. 30-37, "B" is the background color, number to 40-47. With \ e [m ending color settings, color table as follows:
F. B
30 40 Black
31 41 Red
32 42 Green
3343 Yellow
3444 Blue
3545 purple
3646 cyan
3747 white
according to the color table, applies the character color format, you can command the terminal to linux personalize the colors. For example, to set the format of the command line for the green on black, shows the current user's account name,
the first name of the host, complete the current working directory name, 24-hour time format, you can use the following command:
# PS1 = ' [\ [\ e [32; 40m \] \ u @ \ h \ w \ t] \ $ '

Guess you like

Origin www.cnblogs.com/gyrgyr/p/11858438.html