Bug #74562 Set terminal title option
Submitted: 25 Oct 2014 8:32 Modified: 17 Jul 2015 13:56
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: Command-line Clients Severity:S4 (Feature request)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any
Tags: MySQL, terminal, title

[25 Oct 2014 8:32] Daniël van Eeden
With mysql you can set the prompt with MYSQL_PS1 or "\R", but you can't set the window title to something useful.

It can be done manually by running
\! echo -ne "\033]2;SOME TITLE HERE\007"
(and then "\c as the client gets confused by the ;)

How to repeat:
Start mysql client and check the window title.
Is it useful? How can it be changed to something useful?

Suggested fix:
Do something like this from mysql (and mysqldump, etc.?)
#include <stdio.h>

void main() {
  printf("Now changing the terminal title...\n");

Be aware of things like Bug #25143

Maybe add an config option in the mysql or client section for this.

I don't know if this works on windows with cmd.exe, PowerShell and/or Console2.
For screen it sets the window title, but it doesn't change the session title.

Maybe add an client command:
mysql> windowtitle \u@\h
mysql> \A mysql-dev

Some very very basic concept:
diff --git a/client/mysql.cc b/client/mysql.cc
index 450bda0..ed13e35 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1208,6 +1208,7 @@ int main(int argc,char *argv[])
                             getenv("MYSQL_PS1") : 
                             "mysql> ",MYF(MY_WME));
   current_prompt = my_strdup(default_prompt,MYF(MY_WME));
+  printf("\033]2;%s\007", current_prompt);
   outfile[0]=0;                        // no (default) outfile
[17 Jul 2015 13:56] Georgi Kodinov
Thank you for the reasonable feature request.