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 show absolute path, and add [] brackets.
-
- First, modify the/etc/bash. bashrc file.
Leo @ Leo-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
Leo @ Leo-LAPTOP :~ $ Sudo Vim/etc/bash. bashrc
# PS1 = 'U @ H: W $'
PS1 = '[U @ H: W] $'
- Finally, modify. bashrc file
Leo @ Leo-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] $
Relative to the direct use of exportPS1 = "", 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.
(Original address:
Http://xieshaohu.wordpress.com/2010/07/26/ubuntu%E8% AE %BE%E7%BD%AEredhat%E9%A3%8E%E6%A0%BC%E7%9A%84shell%E6%8F%90%E7%A4%BA%E7%AC%A6ps1%E5%B1%9E%E6%80%A7/