Pager for mysql command line interface
mypager is a tool meant to be used with the MySQL and PostgreSQL command line clients on unix platforms.
Its goal is to ease the reading of resultsets, doing 2 things:
Here is a sample output:
It currently requires perl 5.8, preferably with the Term::ReadKey module
(should work without, using the
You can either simply copy the script to the location you wish, or use
To use it you'll just have to tell your mysql client to use it as a pager:
mysql> pager /path/to/mypager.pl
or edit your
[mysql] pager = /path/to/mypager.pl
The script was originaly designed to work with MySQL, but an option exists in PostgreSQL client that format output as mypager expects it.
Unlike the mysql client, there is no specific option for the PostgreSQL pager, you'll have to use the
PAGER environment variable, for example:
export PAGER=/path/to/mypager.pl psql --stuff
Or in your
alias psql="PAGER=/path/to/mypager.pl psql"
Then, you'll have to edit your
.psqlrc file to set 2 default options:
-- Headers and surrounding pipes for columns \pset border 2 -- mypager will decide when to switch to less, but will always add color \pset pager always -- You may want null to be NULL, at your discretion -- \pset null NULL
The configuration file is located in
A default configuration is present at the end of the script itself, should you wish to modify it instead.
You can use
mypager.pl --installconf to write the default configuration to
Current available styles are
header and row styles are used for the
\G option of the mysql client (vertically formated output)
You can use any recognized value of the Term::ANSIColor module, and combine them as you please.
Some valid examples:
bold blue, or
underline white on_black