Linux terminal prompt path length modification method

  
                

The default path under Linux system is usually long, it seems very inconvenient, then is there any way to modify the length of the Linux default path hint? Let's learn how to modify the terminal prompt path length under Linux with Xiaobian.

Basically Linux system default path prompt for the full path, although the full path but really long, looks very convenient, may sometimes refer to the total width It looks dazzling, 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$

Basically occupy 80% of the width of the terminal, if you can change to just display the name of the last folder!

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

Locate the text above and note the value of the environment variable for PS1,\\u Is the current user, \\h is the host name, \\w is to display the full path, \\W is to display a simple path, turn w into W!

As for if or else, you can try it, my is effective.

Execute the command after modification

The code is as follows:

$ source ~/.bashrc

can be applied! The following results

linuxidc@ubuntu:commercials$

The above is the way to modify the length of the terminal prompt path under Linux, if you think the default path of the Linux system is too long, try The method described above, the modified path length is shortened a lot, and does not affect the use.

Copyright © Windows knowledge All Rights Reserved