What if the Linux (Ubuntu) terminal command Prompt is too long?

Source: Internet
Author: User

Due to the frequent use of the end (Zhuang) side (BI), each opening is the sauce of the drop:

or after entering a few levels of directory, it becomes Jiangzi:

True XX ugly! And just lose a few orders. What do we do? Very simple, in two steps:

STEP1: Modify Computer name

As above, "@" and ":" Between the host name, that is, chris-laptop-thinkpad-x240, for example, can be changed to X240

(1) Modify/etc/hostname sudo vim/etc/hostname , the file in a host name, instead of X240:

(2) Modify/ect/hosts sudo vim/etc/hosts to change the chris-laptop-thinkpad-x240 in the file to X240:

OK, turn off the terminal, turn it back on, and see if it's refreshing a lot? Such as:

However, if you enter a directory level that is deep, it becomes Jiangzi:

Never mind, then do STEP2.

SETP2: Modifying PS1 in ~/.BASHRC

The role of the variable PS1 is to set the command prompt, with PS1 values set in the ~/.BASHRC in 3 places, such as:

Briefly describe the meaning of each parameter:

\u Currently logged in User name
\h Current computer name (e.g. Ubuntu)
\h The domain name of the current computer, for example (ubuntu.ubuntu.com)
\w Full path of the current directory
\w Current directory
\$ General user for $,root user for >

So we just need to change the PS1 in the "\w" to "\w", we go. BASHRC in the fault, it does not map. After you change it, you need to reload it. BASHRC will take effect, run the following command: source ~/.BASHRC

Once again into the/HOME/CHRIS/CODE/SHELL/TEST1/TEST2/TEST3 directory, the interface is as follows, done ~

So the question is, what do you want to see in the current full path? Try "pwd":

What if the Linux (Ubuntu) terminal command Prompt is too long?

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.