Ubuntu sets the RedHat style SHELL prompt PS1 attribute

Source: Internet
Author: User
By default, Ubuntu kernel outputs the complete path. When the path name is long, the prompt method is unfriendly. Modify the settings of the PS1 variable by following these steps to allow the terminal to output the relative path. Similar to the Red Hat system. Change idea: Change w to W to show absolute path, and add [] brackets. First modify the/etc/bash. bashrc file www.linuxidc.com @ linuxidc-laptop :~ $ Sudovim/etc/bash. bashrc modify the following content:

By default, Ubuntu kernel outputs the complete path. When the path name is long, the prompt method is unfriendly. Modify the settings of the PS1 variable by following these steps to allow the terminal to output the relative path. Similar to the Red Hat system. Change idea: Change w to W to show absolute path, and add [] brackets.

First, modify the/etc/bash. bashrc file.
Www.linuxidc.com @ linuxidc-laptop :~ $ Sudo vim/etc/bash. bashrc
Modify the following content:
# PS1 = '$ {debian_chroot: + ($ debian_chroot)} u @ h: w $'
PS1 = '[$ {debian_chroot: + ($ debian_chroot)} u @ h: W] $'
Modify the/etc/profile file
Www.linuxidc.com @ linuxidc-laptop :~ $ Sudo vim/etc/bash. bashrc
# PS1 = 'U @ h: w $'
PS1 = '[u @ h: W] $'
Finally, modify the. bashrc file in the user directory.
Www.linuxidc.com @ linuxidc-laptop :~ $ Sudo vim. bashrc
# PS1 = '$ {debian_chroot: + ($ debian_chroot)} [33 [01; 32 m] u @ h [33 [00 m]: [33 [01; 34 m] w [33 [00 m] $'
PS1 = '[$ {debian_chroot: + ($ debian_chroot)} [33 [01; 32 m] u @ h [33 [00 m]: [33 [01; 34 m] W [33 [00 m] $ '# PS1 =' $ {debian_chroot: + ($ debian_chroot)} u @ h: w $'
PS1 = '[$ {debian_chroot: + ($ debian_chroot)} u @ h: W] $'
After all the preceding modifications are completed, you can log on to logout again to see the modified results.
Before modification
Leo-laptop:/var/lib/tomcat $
After modification
[Leo-laptop: tomcat] $
Compared with the direct use of export PS1 = "", this modification method retains the terminal title bar display complete path function.

If you want to enrich the color of the terminal, we can enable ~ /. The force_color_prompt = yes parameter in bashrc. In this way, colors are used to differentiate different items and improve readability.

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.