MYPAGER(1)

πŸ“¦
version 0.6.3 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– NAME πŸ’–

mypager β€” bestie, it adds color to your mysql / psql clients' text output πŸ’…


πŸ¦‹ SYNOPSYS πŸ¦‹

Okay so picture this: a pager tool that sprinkles color onto the query results coming out of your MySQL or PostgreSQL command line clients. That's her. That's the whole job. ✨

She will also automatically pull in less when your terminal can't fit the full result in one page β€” like, if it's too much for one screen, she calls in backup. 🫢

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

And to make that happen you must configure them properly. No skipping this part, fr fr. 😭

USAGE (MYSQL)

Inside the mysql client, use the pager command, then vibe-check it with a simple select:

pager mypager
select 1;

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

In $HOME/.my.cnf:

[mysql]
pager = mypager

USAGE (PSQL)

Unlike the mysql client, there is no specific option in the psql client for this β€” so 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 🌸

Your config lives at $HOME/.mypager.conf, and you can create a brand new configuration file with the current defaults by using mypager --installconf β€” so easy, so slay. πŸŽ€

It's also found in the script itself, in the __DATA__ section. iykyk.

CONFIGURATION OPTIONS

Possible styles are documented in Term::ANSIColor, and you can combine them β€” for example bold cyan is a valid style. Mix and match, main character energy. πŸ‘‘

  • 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.
Heads up bestie β€” this bug was fixed a while ago, so this option is disabled by default. πŸ’€

And that's the whole page, babes β€” this lil' gem is a Perl doc from the User Contributed Perl Documentation collection, and the version/date on the tin is 2021-01-11. Go make your query results pretty. Periodt. πŸ’œπŸ¦‹

πŸ“¦ where this page comes from