Modify the command line path length in linux.

Source: Internet
Author: User

Modify the command line path length in linux.

The default path prompt is the complete path, so that a line is too long and may occupy the full width! As shown below:

jack@ubuntu:~/trunk-new/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/linux-3.10.17/net/netfilter/commercials$

It basically occupies 80% of the terminal width. If you can change it to show only 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 preceding text. Note that the value of the environment variable in PS1 is the current user, \ h is the host name, \ w is the complete path, and \ W is the simple path, change w to W!

If or else takes effect, you can try it all. Mine is else.

Run the command after modification

$ source ~/.bashrc   

You can apply it! Result

jack@ubuntu:commercials$ 

Is it concise...



How to change the default path of the cd command in linux

Cd ~ Is to jump to the main directory.
So what you need to do is modify the main directory
Usermod-d/home/username
 
In linux, how does one set the default path of a command?

Set the environment variable PATH and add the current PATH "."
Export PATH = $ PATH:. You can write this statement to the user profile file, which takes effect automatically upon each Logon:
Vi ~ /. Bash_profile

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.