MYPAGER(1)

NAME
mypager - add color to mysql/psql clients text output

SYNOPSYS
Pager tool that will add color to query results of MySQL or PostgreSQL command line clients. It will also automatically use less when terminal isn't able to display the full result in one page.

mypager is meant to be used as a pager from the mysql or psql command line clients.

To use it you must configure them properly.

  USAGE (MYSQL)
Inside the mysql client, use the "pager" command, then check using a simple select:

  pager mypager
  select 1;

Alternatively, you can set mypager as the default pager in your client configuration.

In $HOME/.my.cnf:

  [mysql]
  pager = mypager

  USAGE (PSQL)
Unlike the mysql client, there is no specific option in the psql client, you'll have to use the PAGER environment variable:

  PAGER=mypager psql --connect-options

You may wish to add an alias in your preferred shell rc:

  alias psql="PAGER=mypager psql"

Additionally, you'll need to change how query results are shown by editing your $HOME/.psqlrc file:

  -- 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

  CONFIGURATION
Configuration is located in $HOME/.mypager.conf, you can create a new configuration file with the current defaults by using "mypager --installconf"

It is also found in the script itself in the __DATA__ section

CONFIGURATION OPTIONS

Possible styles documented in Term::ANSIColor, you may combine them, for example "bold cyan" is a valid style

"style-int"
    Text style for integer (or float) types. Default: green

"style-null"
    Text style for the NULL value. Default: cyan

"style-nudatell"
    Text style for datetimes (and date) values. Default: yellow

"style-header"
    Text style for row headers. Default: underline

"style-row"
    Text style for row header when mysql is used with the "\G" flag. Default: magenta

"long-lines-to-less"
    Defaults to 1.

    When 1: mypager will switch to less if it encounters any line longer than screen width (even if they fit within the height of the screen)

    When 0: it will only take the height as variable to switch to less.

"less-options"
    Options passed on the the "less" executable, default to "-S" (chop long lines)

"less-options-overrides-env"
    Defaults to 0

    If the $LESS environment variable is already set, the default is to set our config options ("less-options") with a lower priority (in case of conflicts) Set to 1 to "override" the environment variable options

use-less
    Determine when mypager will use the less executable Valid options: "auto", "always", "never", default is "auto"

fix-utf8
    Use to "fix" broken MySQL client UTF-8 output.

    This bug was fixed a while ago, so this option is disabled by default