Linux terminal change prompt

Source: Internet
Author: User

Open ~/.BASHRC to see what the command prompt is: \[email protected]\h\w\$

\u represents the user name, \h represents the host name, \w represents the current directory, \$ represents a command prompt (ordinary user $, Super User #)

This command prompt is a bit long, very in the way, \[email protected]\h can be deleted, only show \w\$ is very good

Instead: ps1= ' \[\033[1;3;32m\]\w\[\033[31m\]\$\[\033[0m\] '

If you change to ps1= ' \033[1;3;32m\]\w\033[31m\]\$\033[0m\] ', the system will incorrectly understand the length of the string, causing the system to understand the position of the cursor wrong, There will be a long command back to the beginning of the situation. The following link is particularly clear about this issue http://mywiki.wooledge.org/BashFAQ/053#CA-3f52bac3b5ad40d98d0fa76a95be9049141bfced_5

The escape character must be placed between \[and \], and this rule applies only when defining PS1. In other places, the escape sequence is placed between \001 and \002.

About color escaping, run the following script and know it all.

#!/bin/bashcat << haha You can write like this: \033[one;two;three m this is called ANSI color. "ECHO-E" can use escapes! For more infomation, try "mans echo" Haha#character attributesa= (normal 0 Bold 1 Dim 2italic 3under 4blink 5six 6revert 7con Ceal 8delete 9)  #forecolorb = (Black 30red 31green 32yellow 33blue 34magenta 35cyan 36white pns) #backcolorc = (Black 40re D 41green 42yellow 43blue 44magenta 45cyan 46white) function Show () {while Test $#-gt 0;doecho-  E "\033[${2}m Weidia o\033[0m    "| column-tshift 2done}show ${a[*]}echo ===============fore color ======================show ${ B[*]}echo ================back color ====================show ${c[*]}echo ================random =================== =====echo-e "\033[${b[3]};${c[1]}m Weidiao is great\033[0m"

Linux terminal change prompt

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.