Everybody who uses psql uses less pager. It is working well, but there is not any special
support for tabular data. I found few projects, but no one was completed for this purpose.
I decided to write some small specialized pager for usage as psql pager.
This pager can be used from mysql and pgcli clients too.
- possibility to freeze first few rows, first few columns
- possibility to use fancy colors - like
mcvieworFoxPro
-amenu will use ascii borders-bblack/white theme-Xdoesn't clean screen on the end-s Nuse theme (default theme is mc theme)-c Nfreeze first N columns-f fileopen file (default stdin)--force-uniborderreplace ascii border by unicode borders-g --hilite-searchdon't highlight lines for searches-G --HILITE-SEARCHdon't highlight lines for searches ever--helpshow this help-i --ignore-caseignore case in searches that do not contain uppercase-I --IGNORE-CASEignore case in all searches--less-status-barstatus bar like less pager--line-numbersshow line number column--no-mousewithout own mouse handling (cannot be changed in app)--no-soundwithout sound effect-F,--quit-if-one-screenquit if content is one screen-V,--versionshow version--no-cursorthe line cursor will be hidden--no-commandbarthe bottom bar will be hidden--no-topbarthe top bar will be hidden--no-barsboth bars will be hidden--tabular-cursorcursor is displayed only for table--only-for-tablesuse std pager when content is not a table--bold-labelsbold font for row, column labels--bold-cursorbold font for cursor
- black & white
- Midnight Commander like
- FoxPro like
- Pdmenu like
- White theme
- Mutt like
- PCFand like
- Green theme
- Blue theme
- Word Perfect like
- Low contrast blue theme
- Dark cyan/black mode
- Paradox like
- dBase IV retro style
- dBase IV retro style (Magenta labels)
- Red white theme
- Simple theme
- Solarized dark theme
- Solarized light theme
- Gruvbox light theme
- Tao Light theme
- 0, 1, 2, 3, .., 9 - freeze first N columns
- KEY_UP, k - navigate backward by one line
- KEY_DOWN, j - navigate forward by one line
- KEY_LEFT, h - scroll to left
- KEY_RIGHT, l - scroll to right
- Ctrl+Home, g - go to the start of file
- Ctrl+End, G - go to the end of file
- H - go to first line of current window
- M - go to half of current window
- L - go to end of current window
- PPAGE, Ctrl+b - backward one window
- NPAGE, Ctrl+f, space - forward one window
- HOME, ^ - go to begin of line, first column
- END, $ - go to end of line, last column
- Ctrl+e - scroll a window down
- Ctrl+y - scroll a window up
- Ctrl+d - forward a half window
- Ctrl+u - backward a half window
- s - save content to file
- / - search for a pattern which will take you to the next occurrence
- ? - search for a pattern which will take you to the previous occurrence
- n - for next match
- N - for next match in reverse direction
- Alt+c - switch (on, off) drawing line cursor
- Alt+m - switch (on, off) own mouse handler
- Alt+n - switch (on, off) drawing line numbers
- Mouse button wheel - scroll vertical
- Alt+ Mouse button wheel - scroll horizontal
- F9 - show menu
- q, F10, Esc Esc, Esc 0 - quit
- Alt+q - quit wit raw (unformatted) output
- Alt+k - switch bookmark
- Alt+j - go to next bookmark
- Alt+i - go to previous bookmark
\pset linestyle unicode \pset border 2
some possible configuration:
-- Switch pagers with :x and :xx commands \set x '\\setenv PAGER less' \set xx '\\setenv PAGER \'pspg -bX --no-mouse\'' :xx
MariaDB [sakila]> pager pspg -s 14 -X --force-uniborder --quit-if-one-screen PAGER set to 'pspg -s 14 -X --force-uniborder --quit-if-one-screen' MariaDB [sakila]> select now(); MariaDB [sakila]> select * from nicer_but_slower_film_list limit 100;
LC_CTYPE should be correct.
Some linker issues can be fixed by:
I changed gcc -lncursesw pager.c -o pspg -ggdb to gcc pager.c -o pspg -ggdb -lncursesw
On some old systems a compilation fails with error
/home/user/Src/pspg-0.6/src/pspg.c:2403: undefined reference to `set_escdelay`
In this case comment line with function set_escdelay
When you compile code from source, run ./configure first. Sometimes ./autogen.sh first
If you would to display UTF-8 characters, then pspg should be linked with ncursesw
library. UTF-8 characters are displayed badly when library ncursesw is used. You can
see broken characters with incorrect locale setting too.
You can check wide chars support by pspg --version. Row ncurses with wide char support
is expected. Re-run configure with --with-ncursesw option. When this command fails check
if development package for ncuresesw library is installed.
# dnf install pspg
The pspg is available from community repository https://yum.postgresql.org/packages.php
# apk add pspg
# emerge -av dev-db/pspg
The Arch User Repository contains two versions:
Use the AUR helper of your choice or git and makepkg to install pspg.
# pkg install pspg
# brew install pspg
# brew install pspg
# port install pspg
There are few issues requires manual code changes for successful compilation - we successfully
tested pspg, but although pspg was linked with ncursesw libraries, the utf8 encoding support
didn't work fully correctly - probably due some issues in libc library. There are problems with
chars encoded to 3bytes - unicode borders, .. Two bytes unicode chars should be displayed well.
You can use pspg with usual accented chars, but unicode bordes should not be used. Replacement
ascii borders by special borders chars (by ncurses technology) works well - looks on Options|Force unicode borders
option.
-
Solaris
makedoesn't support conditional statements - should be removed So, remove unsupported functionality fromMakefile(ifdef,endif), replace-includebyincludefirst. -
After running
configureremove link ontermcaplibrary fromconfig.make. It is garabage produced byreadlineautomake script. Combination withncurseslibraries makes some linking issues.
export CURSES_CFLAGS="-I/usr/include/ncurses/"
export PANEL_LIBS="-lpanelw"
./configure
export CFLAGS="-m64 -I/opt/csw/include"
export LDFLAGS="-L/opt/csw/lib/64 -R/opt/csw/lib/64"
export PKG_CONFIG_PATH="/opt/csw/lib/64/pkgconfig"
./configure
- Store data in some column format (now data are stored like array of rows). With this change can be possible to operate over columns - hide columns, change width, cyclic iteration over columns, change order of columns, mark columns and export only selected columns (selected rows).
This project uses st_menu library - implementation of CUA menubar and pulldown menu for ncurses https://github.com/okbob/ncurses-st-menu
If you like it, send a postcard from your home country to my address, please:
Pavel Stehule
Skalice 12
256 01 Benesov u Prahy
Czech Republic
I invite any questions, comments, bug reports, patches on mail address pavel.stehule@gmail.com


