Consider the following setting for MySQL_PS1
:
GREEN="$(echo -e '33[01;32m')"
BLUE="$(echo -e '33[01;34m')"
RESET="$(echo -e '33[00m')"
export MYSQL_PS1="${GREEN}STAGING-\d${BLUE} >${RESET} "
When I start mysql
, and type a command that is longer than the visual line length, it wraps without a new line, overwriting the beginning of line.
I tried the [ ]
trick mentioned here from here.
export MYSQL_PS1="[${GREEN}]STAGING-\d[${BLUE}] >[${RESET}] "
Unfortunately, it produced this prompt instead of correctly excluding the escape characters from the line length.
] >[] >[] ] >[] ]STAGING-d[] >[] STAGING-messenger[] >[]
Is there a way to set colors in MYSQL_PS1
without messing up the estimated line length?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…