colour-mysql-console icon indicating copy to clipboard operation
colour-mysql-console copied to clipboard

Colour mysql shell prompt

Open arsari opened this issue 8 years ago • 5 comments

Hello,

How can I colour the mysql shell prompt using grc?

I change the mysql shell prompt using this: export MYSQL_PS1="mysql_\d>_" which result on: mysql [database]>

I want to colour the database name.

arsari avatar Dec 12 '17 16:12 arsari

Hello.

There is a trick described in https://superuser.com/questions/397183/mysql-command-line-color-prompt

~MySQL client does not support standard bash color sequences, so~ you have to use alias wrapper. I'll commit an example later, thanks.

Update: you can use color sequences in mysql promt. That works on my machine:

export MYSQL_PS1=$(echo -e "\033]0;\u@\h [\d]\007\u@\h [\d]> ") 

nitso avatar Jan 12 '18 14:01 nitso

Hello,

Thank you for responding to our question. I try the referenced link and the suggested export but doesn't work in my mac... :(

arsari avatar Jan 12 '18 17:01 arsari

Do you have any colors in your terminal? I guess it could be swittched off. You can try to check information there: https://stackoverflow.com/questions/1550288/os-x-terminal-colors

I don't have mac right now, so I can't test it myself.

nitso avatar Jan 12 '18 19:01 nitso

Yes, I have colors in my terminal. I try different suggestions from different sources trying to color MySQL prompt but nothing work. That's why I create this issue/question since your GitHub for color MySQL prompt work excellent...

arsari avatar Jan 13 '18 04:01 arsari

This works only for mysql client using readline (<=5.6.4). Use mysql --version to check. @arsari @nitso

biao-biao avatar Sep 05 '19 07:09 biao-biao