Bug #74562 Set terminal title option

Submitted: 25 Oct 2014 8:32 Modified: 17 Jul 2015 13:56
Reporter: Daniël van Eeden Email Updates:
Status: Verified Impact on me:
None 
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
Description:
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");
  printf("\033]2;myuser@myhost:mydb\007");
  fflush(stdout);
  sleep(3);
}
======================================================

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);
   prompt_counter=0;
 
   outfile[0]=0;                        // no (default) outfile
======================================================
[17 Jul 2015 13:56] Georgi Kodinov
Thank you for the reasonable feature request.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.