LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

pspg

Unix pager designed for tables and PostgreSQL output

TLDR

Use as the pager for psql
$ export PAGER=pspg
copy
View a CSV file
$ pspg --csv < [file.csv]
copy
View a TSV file
$ pspg --tsv < [file.tsv]
copy
Open a file directly
$ pspg -f [file.txt]
copy
Set color style
$ pspg -s [5] < [file.csv]
copy
Freeze first N columns while scrolling
$ pspg --csv -c [2] < [file.csv]
copy
Exit if content fits on one screen
$ pspg -F < [file.txt]
copy
Use with psql in streaming mode
$ psql -c "SELECT * FROM table" | pspg --stream
copy

SYNOPSIS

pspg [options] [-f file]

DESCRIPTION

pspg is a Unix pager with rich functionality designed for working with tables. Originally created for PostgreSQL's psql, it also supports MySQL and works as a general CSV/TSV viewer. It features frozen column headers, searching, row/column/block selection, clipboard export, and mouse support.Key features include freezable columns with -c, multiple color styles selectable with -s, vertical and horizontal scrolling, and the ability to directly query databases with -q. In streaming mode (--stream), it can display continuously updating output such as psql's \watch results.

PARAMETERS

-f, --file FILE

Open specified file.
-F, --quit-if-one-screen
Exit if content fits on one screen.
--csv
Read input as CSV format.
--csv-separator CHAR
Specify CSV field separator character.
--csv-header on|off
Control header line usage for CSV input.
--tsv
Read input as TSV format.
--stream
Read input continuously in streaming mode.
--querystream
Read a stream of queries from pipe or file.
-c, --freezecols N
Freeze first N columns (0-9).
-s, --style N
Set color style (0-22).
-b, --blackwhite
Use black and white color style.
-a, --ascii
Force ASCII characters for borders.
-i, --ignore-case
Ignore case in searches without uppercase characters.
-I, --IGNORE-CASE
Ignore case in all searches.
-g, --hlite-search
Don't highlight search results.
-G, --HILITE-SEARCH
Don't highlight search result lines.
--line-numbers
Show line number column.
--no-mouse
Disable custom mouse handling.
--no-bars
Hide bottom and top bars.
--no-cursor
Hide row cursor.
--no-scrollbar
Hide scrollbar.
--no-sound
Disable beep on scroll limit.
--vertical-cursor
Display vertical column cursor.
--bold-labels
Make row and column labels bold.
--force-uniborder
Replace ASCII borders with Unicode borders.
--only-for-tables
Use standard pager when content is not a table.
--on-sigint-exit
Exit on Ctrl+C or Escape.
-X, --reprint-on-exit
Preserve content in terminal after exit.
--ni
Non-interactive mode (CSV and query only).
-q, --query QUERY
Execute specified query.
-w, --watch N
Repeat query or file read every N seconds.
-d, --dbname NAME
Specify database name for direct queries.
-h, --host HOST
Database server host.
-p, --port PORT
Database server port.
-U, --username USER
Database user name.
-V, --version
Show version information.
--help
Show help message.

INSTALL

sudo apt install pspg
copy
sudo dnf install pspg
copy
sudo apk add pspg
copy
sudo zypper install pspg
copy
brew install pspg
copy
nix profile install nixpkgs#pspg
copy

HISTORY

pspg was created by Pavel Stehule (okbob) and is written in C.

SEE ALSO

less(1), psql(1), mysql(1), ov(1)

Copied to clipboard
Kai