Linux Terminal command line prompt art-PS1 advanced

Source: Internet
Author: User
Linux Terminal command line prompt art-PS1 advanced words not to mention, first glance at my command line prompt (a little big): the command line in the figure explains: calendar [calendar date/lunar date and time] calendar [number of directories under the current directory + number of items below the current directory] [current absolute directory] calendar [user name @ host name-number of items... linux Terminal command line prompt art-PS1 advanced words not to mention, first glance at my command line prompt (a little big): the command line in the figure explains: calendar [Gregorian date/lunar date and time] calendar [number of directories under the current directory + number of items below the current directory] [current absolute directory] calendar [user name @ host name-what terminals? _?] Related configuration file global configuration file:/etc/bash. bashrc or/ect/bashrc single-user configuration file: "~" Directory. the bashrc hidden file code corresponds to the following code (the original PS1 can be changed or directly added to the end of the configuration file ): get_ps1 () {Date = $ (date + % F) Time = $ (date-R | cut-c 18-25 | sed's /,//') lunar = $ (lunar 'date + % Y \ % m \ % d' | grep '^ Lunar \: '| awk' {print $3} '| sed's/^ ..... \(. *\).. $/\ 1/') dn = $ (ls-l | grep ^ d | wc-l); fn = $ (expr $ (ls | wc-l) -$ {dn}) Num = $ (echo $ Lunar | wc-m) ["$ Num" = "5"] & space = ''[" $ Num "=" 4 "] & space ='' PS1 = "\ 342 \ 224 \ 214 [\ [\ e [01; 32m \] $ {Date}/$ {Lunar} $ {space} $ {Time} \ [\ e [00m \] \ n \ 342 \ 224 [\ [\ e [01; 34m \] $ {dn} \ [\ e [00m \] + $ {fn}] [\ [\ e [01; 34m \] \ w \ [\ e [00m \] \ n \ 342 \ 224 \ 224 [$ {debian_chroot: + ($ debian_chroot )} \ [\ e [01; 32m \] \ u @ \ h-\ l \ [\ e [00m \] \ 342 \ 225 \ 260 \ 137 \ 342 \ 225 \ 257] \ $ "} PROMPT_COMMAND = get_ps1 if you think the above command line prompt is too complicated, you can also reduce it... If you want to design a command line prompt that you like and is dazzling enough, you must first understand the following. 1) The lunar date is involved. you can find the lunar software package from the source in Ubuntu 12.04 LTS, but it does not exist in Fedora and CentOS, for this reason, I wrote a shell script for converting the Gregorian calendar to the lunar calendar. for details, refer to my Linux shell to implement the conversion of the Gregorian calendar to the lunar calendar. http://www.2cto.com/os/201307/228131.html . 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. http://0xcc.net/jsescape/ Escape, enter the characters you want to escape in the Plain text column, and the character encoding you want in the \ OOO column.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.