← 返回命令列表

Linux command

pspg 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Use as the pager for psql

export PAGER=pspg

View a CSV file

pspg --csv < [file.csv]

View a TSV file

pspg --tsv < [file.tsv]

Open a file directly

pspg -f [file.txt]

Set color style

pspg -s [5] < [file.csv]

Freeze first N columns while scrolling

pspg --csv -c [2] < [file.csv]

Exit if content fits on one screen

pspg -F < [file.txt]

Use with psql in streaming mode

psql -c "SELECT * FROM table" | pspg --stream

说明

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.

参数

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

FAQ

What is the pspg command used for?

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.

How do I run a basic pspg example?

Run `export PAGER=pspg` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -f, --file _FILE_ do in pspg?

Open specified file.