Modify the command prompt line path length under Linux

Source: Internet
Author: User

The default path hint is the full path, so the line is long and may take up the full width, looking very uncomfortable! Just like this.

[Email protected]:~/trunk-new/build_dir/target-mips_34kc_uclibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.17/net /netfilter/commercials$

Basically occupy the width of terminal 80%, if it can be changed to show only the last folder name is good!


Modification Method:

Vim ~/.BASHRC

Search PS1

If ["$color _prompt" = yes]; Then     ps1= ' ${debian_chroot:+ ($debian _chroot)}\[\033[01;32m\]\[email protected]\h\[\033[00m\]:\[\033[01;34m \]\w\[\033[00m\]\$ '     ps1= ' ${debian_chroot:+ ($debian _chroot)}\[email protected]\h:\w\$ ' fi

Find the above text, pay attention to the PS1 environment variable value, \u is the current user, \h is the hostname, \w is the full path, \w is to display a simple path, w into W can be!

As for if or else in effect, you can try it, mine is else in effect.

Execute command after modification

$ source ~/.BASHRC   

You can apply it! The following results


is not very concise ...


Modify the command prompt line path length under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.