Code Monkey home page Code Monkey logo

pspg's Introduction

pspg - Postgres Pager

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.

Main target

  • possibility to freeze first few rows, first few columns
  • possibility to use fancy colors - like mcview or FoxPro

Screenshots

Screenshot

Screenshot

Options

  • -b black/white theme
  • -X doesn't clean screen on the end
  • -s N use theme (default theme is mc theme)
  • -c N freeze first N columns
  • -f file open file (default stdin)
  • --force-uniborder replace ascii border by unicode borders
  • -g --hilite-search don't highlight lines for searches
  • -G --HILITE-SEARCH don't highlight lines for searches ever
  • --help show this help
  • -i --ignore-case ignore case in searches that do not contain uppercase
  • -I --IGNORE-CASE ignore case in all searches
  • --less-status-bar status bar like less pager
  • --no-mouse without own mouse handling (cannot be changed in app)
  • --no-sound without sound effect
  • -F, --quit-if-one-screen quit if content is one screen
  • -V, --version show version

Themes

  1. black & white
  2. Midnight Commander like
  3. FoxPro like
  4. Pdmenu like
  5. White theme
  6. Mutt like
  7. PCFand like
  8. Green theme
  9. Blue theme
  10. Word Perfect like
  11. Low contrast blue theme
  12. Dark cyan/black mode
  13. Paradox like
  14. dBase IV retro style
  15. dBase IV retro style (Magenta labels)

see http://okbob.blogspot.cz/2017/07/i-hope-so-every-who-uses-psql-uses-less.html

Keyboard commands

  • 0, 1, 2, 3, 4 - 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+m - switch (on, off) own mouse handler
  • Mouse button wheel - scroll vertical
  • Alt+ Mouse button wheel - scroll horizontal
  • q, F10, Esc Esc, Esc 0 - quit
  • Alt+k - switch bookmark
  • Alt+j - go to next bookmark
  • Alt+i - go to previous bookmark

Recommended psql configuration

\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

MySQL usage

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;

Note - compilation issue

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

Note - Installation

The pspg is available from community repository https://yum.postgresql.org/packages.php

Gentoo

# emerge -av dev-db/pspg

FreeBSD

# pkg install pspg

macOS (MacPorts)

# port install pspg

Note

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 [email protected]

pspg's People

Contributors

okbob avatar shiar avatar lbschenkel avatar df7cb avatar dmgk avatar titanofold avatar josser avatar rjuju avatar kassandry avatar mnencia avatar kikuchan avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.