If you don't want to talk about it, first glance at my command line prompt (a little big ):
The command line in the figure is as follows:
Calendar [date of the Gregorian calendar/date of the lunar calendar]
Else [number of directories under the current directory + number of items below the current directory] [current absolute Directory]
Users [username @ host name-the number of terminals required _ hosts]
Related configuration files
Global configuration file:/etc/bash. bashrc or/ect/bashrc
Single-user configuration file: "~" . Bashrc files in the directory
Code
The code corresponding to this parameter is as follows (generally, the original PS1 is overwritten by the Add location, which can be modified on the original PS1 or directly added to the end of the configuration file ):
=$( +%=$( -R | -c - | =$(lunar ` +%Y\ %m\ %d` | | | =$( -l | ^d | -l);fn=$( $( | -l) -=$( $Lunar| - = ] && space= = ] && space= =\\\[\[\e[;34m\]${dn}\[\e[00m\]+${fn}][\[\e[;34m\]\\\[${debian_chroot:+($debian_chroot)}\[\e[;32m\]\u@\h-\l \[\e[00m\]\\\\\\\]\$=get_ps1
If you think the above command line prompt is too complicated, you can also reduce it...
What you need to know
If you want to design a command line prompt that you like and is dazzling enough, you should first understand the following.
1) The Lunar date is involved, which can be found in the source in Ubuntu 12.04 LTS.LunarSoftware package, but not in Fedora and CentOS. For this reason, I wrote a shell script for converting the Gregorian calendar to the lunar calendar. For details, see my.
2) escape characters and colors. I am no longer arrogant about this. google's "Linux Command Line color" will have a lot of answers.
3) PROMPT_COMMAND: This is the key to real-time command line. The content of this variable will be executed before the bash prompt is displayed, so the real-time content used above needs it.
4) What should I do if special characters cannot be displayed? You can convert it to character encoding. You can escape it. In the Plain text column, enter the character you want to escape. In the \ OOO column, it is the character encoding you want.