I'm trying to make PS1 configured as follows.Green=\[\e[32;1m\]Red=\e[0;31mPurple=\e[0;35mSTARTCOLOR=\[\e[40m\]ENDCOLOR=\[\e[0m\]export PS1=$STARTCOLOR$Green\u@$Purple\h $Red\w$Green>$ENDCOLOR And I have some questions.What's the difference between [\e[32;1m] and \e[32;1m? Are they the same?After running the 'export PS1' command, it works well, but when I give the input around 20 characters, the characters are overwritten as I attached. What's wrong with this?What's the meaning of STARTCOLOR(\e[40m)/ENDCOLOR(\e[0m)?http://a.imageshack.us/img8/606/resultqm.jpgADDEDAfter some tests, I got the following change could solve the problem. That is, the \e format should be replaced by \[\e format. Red=\\e[1;31m -- not workingRed=\[\e[1;31m\] -- working
bash PS1 setup
bash;prompt
I have a helper function to set prompt, and because I don't want to spend more time for looking for escape code references, I've coded all text color values into it.function set_prompt ( ){    # Prompt setup    # ##################    # Black            \e[0;30m    # Blue             \e[0;34m    # Green            \e[0;32m    # Cyan             \e[0;36m    # Red              \e[0;31m    # Purple           \e[0;35m    # Brown            \e[0;33m    # Gray             \e[0;37m    # Dark Gray        \e[1;30m    # Light Blue       \e[1;34m    # Light Green      \e[1;32m    # Light Cyan       \e[1;36m    # Light Red        \e[1;31m    # Light Purple     \e[1;35m    # Yellow           \e[1;33m    # White            \e[1;37m    local COLOR_DEFAULT='\[\e[0m\]'    local COLOR_BLACK='\[\e[0;30m\]'    local COLOR_BLUE='\[\e[0;34m\]'    local COLOR_GREEN='\[\e[0;32m\]'    local COLOR_CYAN='\[\e[0;36m\]'    local COLOR_RED='\[\e[0;31m\]'    local COLOR_PURPLE='\[\e[0;35m\]'    local COLOR_BROWN='\[\e[0;33m\]'    local COLOR_GRAY='\[\e[0;37m\]'    local COLOR_DARK_GRAY='\[\e[1;30m\]'    local COLOR_L_BLUE='\[\e[1;34m\]'    local COLOR_L_GREEN='\[\e[1;32m\]'    local COLOR_L_CYAN='\[\e[1;36m\]'    local COLOR_L_RED='\[\e[1;31m\]'    local COLOR_L_PURPLE='\[\e[1;35m\]'    local COLOR_YELLOW='\[\e[1;33m\]'    local COLOR_WHITE='\[\e[1;37m\]'    local PS1_SET_TITLE='\[\e]0;\w\a\]'    local PS1_SET_TIME=${COLOR_DEFAULT}\t    local PS1_SET_RET_CODE=${COLOR_L_RED}(\$?)    local PS1_SET_USER=${COLOR_L_GREEN}\u@\h    local PS1_SET_PWD=${COLOR_YELLOW}\w    local PS1_LN_1=${PS1_SET_TITLE}\n    local PS1_LN_2=${PS1_SET_TIME} ${PS1_SET_RET_CODE}     local PS1_LN_2=${PS1_LN_2}${PS1_SET_USER} ${PS1_SET_PWD} ${COLOR_DEFAULT}\n    echo ${PS1_LN_1}${PS1_LN_2}}You can then do:PS1=$( set_prompt )# Use '#' for root shellexport PS1=${PS1}'$ 'unset -f set_promptHere is the link that explains VT100 terminal codes: http://www.termsys.demon.co.uk/vtansi.htm\[ - begin sequence of non-printing characters\] - end sequence of non-printing charactersWhat's the difference between [\e[32;1m] and \e[32;1m? Are they  the same?Not the same, and it should be \[\e[32;1m\]'.  Without[]` it would try to print the sequence in console.What's the meaning of STARTCOLOR(\e[40m)/ENDCOLOR(\e[0m)?STARTCOLOR, means set background to black,ENDCOLOR means reset all text attributes, meaning 'give me default console color'