Modify the linux command prompt line path length

  

The default path prompt is the complete path, so the line is very long, may account for the full width, looking very unhappy! Like the following

jack@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 terminal 80 % width, if you can change to just display the name of the last folder! 

Modification method:

vim ~/.bashrc

Search PS1

56 if [ "$color_prompt" = yes ]; then 57 PS1='${ Debian_chroot:+($debian_chroot)}\\[\\033[01;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\W\\[\\033[00m \\]\\$ ' 58 else 59 PS1='${debian_chroot:+($debian_chroot)}\\u@\\h:\\W\\$ ' 60 fi find the above text, pay attention to the value of the environment variable of 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.

After executing the command,

$ source ~/.bashrc can be applied! The following result 
jack@ubuntu:commercials$ is not very concise. . .
						
Copyright © Windows knowledge All Rights Reserved