okbob/pspg logo

okbob/pspg

Free

Unix pager (with very rich functionality) designed for work with tables. Designed for PostgreSQL, but MySQL is supported too. Works well with pgcli too. Can be used as CSV or TSV viewer too. It supports searching, selecting rows, columns, or block and export selected area to clipboard.

FreeFree tier
Type
Open Source

About okbob/pspg

pspg (Postgres Pager) is a specialized Unix pager designed for browsing tabular data in the terminal. It was created because standard pagers like less lack support for tabular data. pspg integrates seamlessly with psql and other command-line database clients such as mysql, sqlite, pgcli, monetdb, Trino (Presto SQL), usql, sqlcl (Oracle), and nushell. Key capabilities include freezing header rows and columns, sorting by numeric columns, applying visual themes (e.g., mcview, FoxPro), mouse support, and copying selected cell ranges to the clipboard. It can also be used as a CSV or TSV viewer. Installation is available via Debian/Ubuntu, RedHat/Fedora, and homebrew (macOS). Native Windows is not supported but works under WSL2.

Key Features

Freeze first few rows or columns for reference while scrolling
Sort data by a specified numeric column
Fancy themes (e.g., mcview, FoxPro) configurable via config file
Mouse support for selection and navigation
Copy selected range (rows, columns, or block) to system clipboard
Works as a pager for psql, mysql, sqlite, pgcli, monetdb, Trino, usql, sqlcl, nushell
Can be used as a standalone CSV or TSV viewer
Export selected area to clipboard

Pros & Cons

Pros
  • Specially designed for tabular data unlike generic pagers like less
  • Free and open source with active community on GitHub
  • Supports many database clients out of the box
  • Lightweight and fast in terminal environments
  • Configurable themes and mouse interaction
  • Clipboard integration for copying selections
Cons
  • No native Windows support; requires WSL2 for Windows use
  • Limited to terminal-based workflows (no GUI)
  • No built-in data transformation or analysis capabilities beyond sorting
  • Not for non-tabular file formats

Best For

Viewing and navigating query results in psql or other database clientsQuickly inspecting CSV or TSV files in terminalFreezing header rows/columns while analyzing large dataset outputsSorting tabular data by column values without external toolsCopying specific table cells or ranges to clipboard for further use

FAQ

How do I install pspg?
On Debian/Ubuntu: sudo apt-get install pspg. On RedHat/Fedora: sudo dnf install pspg. On macOS via Homebrew: brew install pspg. For other systems, build from source on GitHub.
How do I use pspg with psql?
Set the environment variable PSQL_PAGER to 'pspg', optionally with options like -X (preserve after exit) and -b (black-white theme). Example: export PSQL_PAGER='pspg -X -b'.
Does pspg support MySQL or other databases?
Yes, pspg works with mysql, sqlite, pgcli, monetdb, Trino, usql, sqlcl (Oracle), and nushell, in addition to PostgreSQL.
Can I use pspg to view CSV files?
Yes, pspg can be used as a CSV or TSV viewer by passing the filename as an argument or piping the file to it.
Does pspg work on Windows?
Native Windows is not supported, but pspg works well inside WSL2 (Windows Subsystem for Linux). Installation inside WSL2 follows the same method as the Linux distribution used.