How to modify the path length of terminal prompt by Linux
This article introduces the knowledge of "how to modify the path length of terminal prompt in Linux". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
Basically, the default path prompt under Linux system is the complete path, although it is a complete path, it is really long and looks very inconvenient, which means that sometimes it may occupy the entire width and look dazzling, just like the following example:
linuxidc@Ubuntu:~/trunk-new/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.17/net/netfilter/commercials$
Basic occupation of 80% of the terminal width, if you can change to show only the name of the last folder would be good!
Modification method:
The code is as follows:
vim ~/.bashrc
Search PS1
The code is as follows:
if [ "$color_prompt" = yes ]; then
PS1=‘${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]$ ’
else
PS1=‘${debian_chroot:+($debian_chroot)}\u@\h:\W$ ’
fi
Find the above text, pay attention to the value of PS1 environment variable,\u is the current user,\h is the host name,\w is to show the complete path,\W is to show the simple path, w can be changed to W!
If it is, or if it is, then I will try it out.
Execute command after modification
The code is as follows:
$ source ~/.bashrc
It can be applied! following results
linuxidc@ubuntu:commercials$
"Linux how to modify the terminal prompt path length" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!