Why do my Bash prompt colors make cursor appear in wrong spot [duplicate]
问题 This question already has an answer here : Adding ANSI color escape sequences to a bash prompt results in bad cursor position when recalling/editing commands (1 answer) Closed 4 years ago . I've got the following bash prompt: # helper function to set colors function ps1c() { tput setaf $1; } PS1='$(ps1c 243)\h $(ps1c 177)\W $(ps1c 214)$ \[\e[m\]'; When typing, sometimes my cursor returns to the left side of the screen and looks like it's overwriting the prompt. Also, when using the up arrow