MYPAGER(1) | User Contributed Perl Documentation | MYPAGER(1) |
mypager - add color to mysql/psql clients text output
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.
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
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 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
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.
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
This bug was fixed a while ago, so this option is disabled by default
2021-01-11 |