readline commands combined with mysql options . readline accepts commands similar to the main emacs commands (can also be installed on vi), or the CTRL-a example returns you to the beginning of the line.
combined with set horizontal-scroll-mode On
, readline , which you set to ~/.inputrc
, which allows you to enter your input in 1 straight line by placing the cursor at the very end. Combine it with CTRL-a to jump directly to the beginning, and this is pretty convenient.
~/.inputrc
:
$if Mysql set horizontal-scroll-mode On`
(some systems, OSX 10.5, for sure, I believe that libedit is used instead of libline, in which case you need to put all this in ~/.editrc
if you are not sure that your system issues the mysql --version
command)
To search for the commands you issued, you also have CTRL-r
, which allows you to enter a term, and your story will look for the latest event.
interesting teams are:
- CTRL-P go to previous command in history
- CTRL-N go to next command in history
- CTRL-R Reverse Search Your History
- CTRL-S Search Forward Through History
- CTRL-A Move cursor to beginning of line
- CTRL-E Move cursor to end of line
- CTRL-W removes Word back
- ALT-D removes the word forward
- CTRL-F moves the cursor forward 1 character
- CTRL-B moves the cursor back 1 character
- ALT-F move the cursor forward 1 word
- ALT-B moves the cursor back 1 word
- ALT-_ undo
Depending on your shell and base code, they may not work or intercept. For example, on Konsole, which I use on kde, I had to turn off flow control in advanced settings in order to enable CTRLs among others.
Finally, mysql also provides the \ e command, which allows you to edit your commands in your general file editor, if vi or emacs isn't your thing, try nano, it works easily and well. The main disadvantage of using this is that when scrolling through newlines, the bu tabs and spaces are ignored. This is the only thing, but OS X should do it there perfectly, I canβt check, because I donβt own Apple computers, sorry. :)
To make this command easier to use, you can put the readline string macro in ~/.inputrc
for example Control-o: "\\e;\n"
will bind CONTROL-o to \ e; then enter for immediate execution. (see Keyword Section )