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.