MySQL command line color prompt

colorsMySQLprompt

I want to add colors to the MySQL command line color prompt.

I have so far in a script (database.sh):

mysql -uroot -hlocalhost -A --prompt="\u@\h:\d> "

I would like root to be red, @ to be blue, localhost to be green and database to be cyan:

root@localhost:database>

Is it possible to do this in my script?

Best Answer

Don't listen to people who say you can't. Here:

$ alias colormysql=$(echo -e 'mysql --prompt="\x1B[31m\\u\x1B[34m@\x1B[32m\\h\x1B[0m:\x1B[36m\\d>\x1B[0m "')

Then:

$ colormysql -hHOSTNAME -uUSERNAME -pPASSWORD ...
Related Question