Explanation: bash has to calculate the length of the prompt so it can place the cursor correctly when you press home. For whatever reason bash does not consider color codes as taking no space on screen. You have to explicitly tell bash that the color codes do not take up space by wraping them in escaped square brackets.