Create a friendly Shell prompt in Linux

Source: Internet
Author: User
First, let's take a look at the original setup prompt ~ In the bashrc configuration file, the initial definition is as follows: setafancyprompt (non-color, unlessweknow

First, let's take a look at the original setup prompt, in the ubuntu feisty ~ /. In the bashrc configuration file, the initial definition is as follows:

  1. # Set a fancy prompt (non-color, unless we know we "want" color)
  2. Case "$ TERM" in xterm-color)
  3. PS1 = '$ {debian_chroot: + ($ debian_chroot)} [33 [01; 32 m] u @ h [33 [00 m]: [33 [01; 34 m] w [33 [00 m] $'
  4. ;;
  5. *)
  6. PS1 = '$ {debian_chroot: + ($ debian_chroot)} u @ h: w $'
  7. ;;
  8. Esac

Let's only look at this line:PS1 = '$ {debian_chroot: + ($ debian_chroot)} u @ h: w $'

Environment variable:

Note:$ {Xxxx} is a variable, u represents the current user, h represents the host name, w represents the working path, and $ is '$' (escape symbol, such as n, t)

Color code:

[33 [01; 32 m] is a standard color code consisting of a semi-Square brackets. The second '[' is followed by the standard ANSI color code.

My shell prompt is like this:

  1. PS1 = '$ {debian_chroot: + ($ debian_chroot)} [33 [01; 32 m] u [33 [01; 35 m] @ [33 [01; 36 m] h [33 [00 m]: [33 [01; 34 m] wn [33 [01; 39 m] $? [33 [01; 38 m] $'

[$? Returns the return code of the last operation. 0 indicates that the operation is successful.]

Related Article

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.