You can also auto-complete based on the command history. Start typing, then invoke the keys which are bound to ed-search-prev-history
and ed-search-next-history
. This applies if mysql comes with libedit support. The default keybindings are Ctrl-P and Ctrl-N, but this can be customized in .editrc. My example for Ctrl-up and Ctrl-down:
# start typing, then press Ctrl-Up
bind "\e[1;5A" ed-search-prev-history
# start typing, then press Ctrl-Up, then Ctrl-Down
bind "\e[1;5B" ed-search-next-history
Previously, mysql was based on readline, and then history-search-backward
and history-search-forward
are the correct commands. Configuration then was by means of .inputrc. Same example as above:
# these are the key bindings for the readline library
# start typing, then press Ctrl-Up
"\e[1;5A": history-search-backward
# start typing, then press Ctrl-Up, then Ctrl-Down
"\e[1;5B": history-search-forward
So, say you started typing sel
and invoke Ctrl-Up, select * from some_long_table_name
would come up if that is a command I have used earlier.