Documentation Home
MySQL Shell 8.0
Related Documentation Download this Manual
PDF (US Ltr) - 491.7Kb
PDF (A4) - 492.0Kb
HTML Download (TGZ) - 98.8Kb
HTML Download (Zip) - 110.5Kb


MySQL Shell 8.0  /  MySQL Shell Code Execution  /  Editing Code

5.4 Editing Code

MySQL Shell's \edit command (available from MySQL Shell 8.0.18) opens a command in the default system editor for editing, then presents the edited command in MySQL Shell for execution. The command can also be invoked using the short form \e or key combination Ctrl-X Ctrl-E. If you specify an argument to the command, this text is placed in the editor. If you do not specify an argument, the last command in the MySQL Shell history is placed in the editor.

The EDITOR and VISUAL environment variables are used to identify the default system editor. If the default system editor cannot be identified from these environment variables, MySQL Shell uses notepad.exe on Windows and vi on any other platform. Command editing takes place in a temporary file, which MySQL Shell deletes afterwards.

When you have finished editing, you must save the file and close the editor, MySQL Shell then presents your edited text ready for you to execute by pressing Enter, or if you do not want to proceed, to cancel by pressing Ctrl-C.

For example, here the user runs the MySQL Shell built-in report threads with a custom set of columns, then opens the command in the system editor to add display names for some of the columns:

\show threads --foreground -o tid,cid,user,host,command,state,lastwait,lastwaitl
\e
\show threads --foreground -o tid=thread_id,cid=conn_id,user,host,command,state,lastwait=last_wait_event,lastwaitl=wait_length