How to modify the path length of command line prompt under linux
This article mainly explains "how to modify the path length of the command line prompt path prompt under linux". The content of the article is simple and clear, and it is easy to learn and understand. Please follow Xiaobian's train of thought to slowly deepen, together to study and learn "how to modify the path length of the command line prompt path prompt under linux".
Basically, the default path prompt under the Linux system is the complete path, which is really long and inconvenient, which means that sometimes it may occupy the full width and look dazzling, as in 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$
Basically occupy 80% of the width of the terminal, if only can be changed to display only the name of the last folder!
Modify 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 [01Ex32m\]\ u@\ h\ [\ 033 [00m\]:\ [\ 033 [01transfer34m\]\ W\ [\ 033 [00m\]\ $'
Else
PS1='$ {debian_chroot:+ ($debian_chroot)}\ u @\ h:\ W\ $'
Fi
Find the text above and notice the value of the environment variable of PS1.\ u is the current user,\ h is the hostname,\ w is the full path, and\ W is the simple path. Just change w to W!
As for whether if or else is effective, you can try both, mine is else effective.
Execute the command after modification
The code is as follows:
$source ~ / .bashrc
It can be applied! The results are as follows
Linuxidc@ubuntu:commercials$
The modified linux prompt path prompt path length is not very short, the theme is clear and easy to remember?
Thank you for your reading, the above is the content of "how to modify the path length of the command line prompt path prompt under linux". After the study of this article, I believe you have a deeper understanding of how to modify the path length of the command line prompt path prompt under linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!