Change the shell prompt Display Mode

Source: Internet
Author: User

Q: How can I change the shell display mode to [complete working directory of username @ host] $ to [last working directory of username @ host] $

Solution: Add export PS1 = '[/u @/h/W]/$' to. bashrc'

Note:

In Linux, there are two variables for the system prompt: PS1 and PS2. PS1 is the system prompt. The general format is:
[Username @ host
Working directory] #, that is, username + Host Name (generally IP address) + current working directory (you can list the last directory or all directories) + # (root user is #, the average user is $ ).
Enter the first line of PS2, and wait for the prompt entered in the second line. Generally>.

First use echo to display the PS1 parameter, Echo $ ps1, and the result is/S-/V/$ (I added a space in the middle ). According to the definition of characters in environment variables:

 

/D: represents the date, in the format of weekday month date, for example: "Mon Aug 1"
/H: complete host name. For example, if my machine name is fc4.linux, this name is fc4.linux.
/H: only the first name of the host. In the preceding example, the name is FC4, and the name of. Linux is omitted.
/T: The display time is in the 24-hour format, for example, HH: mm: Ss.
/T: The display time is 12 hours.
/A: The display time is in the 24-hour format: hh: mm
/U: Account name of the current user
/V: Bash version information
/W: complete working directory name. In the home directory ~ Replace
/W: Use basename to get the working directory name. Therefore, only the last directory is listed.
/#: Commands issued

 

/$: The prompt character. If it is root, the prompt is: #, and the normal user is: $

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.