The shell terminal only displays the user name, hostname, working directory by default, and sometimes we need to simply tweak the information displayed on the shell terminal to make the work more efficient. For example, we can add time to the shell terminal so that we calculate the time of the script execution as follows:
[[email protected] src]$echo $PS1
[\[email protected]\h \W]$ #读取默认终端显示信息
[[email protected] src]$export PS1="[\[email protected]\h \W \t]$" #给Shell终端加上时间显示
[[email protected] src 16:19:18]$ #时间已经显示出来了
The display of the shell terminal, using the following two environment variables
PS1: Is the user's usual prompt.
PS2: The first line is not finished, wait for the second line to enter the prompt.
[[email protected] src]$echo $PS1
[\[email protected]\h \W]$ #读取默认终端显示信息
To continue to take effect after reboot, just modify the configuration file.
For the current user only need to modify ~/.BASHRC, for all users of the system we modify/ETC/BASHRC.
The default special symbolic meaning in the shell environment:
\d: Represents the date, formatted as weekday month date, for example: "Sun Sep 18″
\h: The full host name. For example: My machine name is: Redhat.linux, then this name is Fc4.linux
\h: Only the first name of the host is taken, as in the example above, then Redhat.linux,.linux is omitted
\ t: Display time in 24-hour format such as: HH:MM:SS
\ t: Display time in 12-hour format
\a: Display time in 24-hour format: hh:mm
\u: Current user's account name
Version information for \v:bash
\w: The full working directory name. Home directory will be replaced by ~
\w: Use basename to get the working directory name, so only the last directory is listed
\#: The first few commands issued
\$: Prompt character, if root, Prompt is: #, normal user is: $
\ n: Line break
Reference Documentation:
Http://www.cnblogs.com/rooney/archive/2012/03/22/2410880.html
Modify Shell terminal prompt information