Mysql Color Scheme

Viewed 17375

Is there a way to set a color scheme for the mysql client? It might sound trivial, but I'd like to be able to set some level of colors for terminal client.

9 Answers

You could use rlwrap if you just want a colour prompt:

% rlwrap --prompt-colour='1;34' mysql

Note: contrary to convention, rlwrap spells colour with a U.

If you want everything in colour, check out acoc - Arbitrary Command Output Colourer. Not sure if it works with interactive programs, you might need to extend it or write your own.

Mysql text client is really basic, if you need something more advanced, you could try MySQL Query Browser, which is a GUI client.

Look up the program GRC on MacPorts.

I'm currently working on getting it running to colorize all of my terminal output. It uses regex to parse everything, so it really comes down to how much regex do you feel like writing.

For colorizing everything you need nothing but a simple echo.
Since mysql has:

system    (\!) Execute a system shell command.

you can easily:

mysql_colorize_prompt_1

But if you want only the prompt be in color use rlwrap

mysql_colorize_prompt_2

And if you want to colorize the result of command you can use grc
It is a script that I think read the underline stdout, stderr and then colorize it. You can configure it. And since it uses to match the result, in configure file you should write regex

here is some screen-shot


More detail about ANSI color:

How to change the output color of echo in Linux

Add this to your ~/.profile [or ~/.bashrc]

export MYSQL_PS1="$(echo -e '\033[1;32mmysql \d> \033[0m')"

You should set color scheme for your terminal emulator or console window.

Related