{"id":13392700,"url":"https://github.com/okbob/pspg","last_synced_at":"2026-01-23T08:06:47.676Z","repository":{"id":43921659,"uuid":"96926243","full_name":"okbob/pspg","owner":"okbob","description":"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. ","archived":false,"fork":false,"pushed_at":"2025-03-13T16:26:05.000Z","size":4650,"stargazers_count":2566,"open_issues_count":1,"forks_count":85,"subscribers_count":46,"default_branch":"master","last_synced_at":"2025-04-02T02:04:15.775Z","etag":null,"topics":["c","csv-viewer","dbcli","monetdb-client","mysql","mysql-client","ncurses","nushell","pager","postgres-pager","postgresql","postgresql-client","psql","terminal","terminal-app","terminal-pager","tui"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/okbob.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-11T18:54:13.000Z","updated_at":"2025-03-25T17:21:07.000Z","dependencies_parsed_at":"2024-03-08T08:26:42.511Z","dependency_job_id":"57b9d069-e3f7-429c-ab11-ad3c89c577cd","html_url":"https://github.com/okbob/pspg","commit_stats":{"total_commits":1210,"total_committers":36,"mean_commits":"33.611111111111114","dds":"0.12066115702479341","last_synced_commit":"294e2f2cc8da5fccf5f60e90bea96b1ed028d32a"},"previous_names":[],"tags_count":153,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okbob%2Fpspg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okbob%2Fpspg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okbob%2Fpspg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okbob%2Fpspg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/okbob","download_url":"https://codeload.github.com/okbob/pspg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247968261,"owners_count":21025820,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","csv-viewer","dbcli","monetdb-client","mysql","mysql-client","ncurses","nushell","pager","postgres-pager","postgresql","postgresql-client","psql","terminal","terminal-app","terminal-pager","tui"],"created_at":"2024-07-30T17:00:35.319Z","updated_at":"2026-01-23T08:06:47.670Z","avatar_url":"https://github.com/okbob.png","language":"C","readme":"[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://stand-with-ukraine.pp.ua)\n\n# pspg - Postgres Pager\n\nEverybody who uses `psql` also uses the `less` pager. Which, while it works well, has no special\nsupport for tabular data. I found a few projects, but none was good enough for this purpose.\nThus I decided to write a small specialized pager to use as a `psql` pager.\n\nThis pager can be used from the following command line clients, too:\n\n- `mysql`\n- `sqlite`\n- [`pgcli`](https://github.com/dbcli/pgcli/)\n- `monetdb`\n- [`Trino (formerly Presto SQL)`](https://trino.io/)\n- [`usql`](https://github.com/xo/usql/)\n- [`sqlcl`](https://github.com/okbob/pspg/#sqlcl) (for oracle)\n- [`nushell`](https://www.nushell.sh/)\n\n## Main target\n\n* ability to freeze the first few rows, or first few columns\n* ability to sort data by the specified numeric column\n* ability to use fancy themes - like `mcview` or `FoxPro` - http://okbob.blogspot.com/2019/12/pspg-themes-what-you-use-it.html\n* mouse is supported and used\n* ability to copy a selected range to the clipboard\n\n## Installation and basic configuration\n\nThe `pspg` can be simply installed from Debian (Ubuntu) repositories. RedHat (Fedora) repositories\ncontains `pspg` too:\n\n    # Debian (Ubuntu)\n    sudo apt-get install pspg\n\n    # RedHat (Fedora)\n    sudo dnf install pspg\n\nBasic configuration is very simple - just set system environment variable `PSQL_PAGER`:\n\n    export PSQL_PAGER='pspg'\n\nor with some common options (`-b` means blackwhite theme, `-X` preserve content after exit):\n\n    export PSQL_PAGER='pspg -X -b'\n\nAttention: options used in command line has higher priority than options specified in configuration file (`~/.pspgconf`).\n\nNative installation on MS Windows is not supported, but `pspg` works well inside `wsl2`.\nInside wsl2 environment, the installation is same like on used Linux system.\n\nInstallation on macOS/homebrew is simple by `brew install pspg`.\n\n## Video presentation\n\n[![Video presentation](https://img.youtube.com/vi/JyxuEkoYDQk/0.jpg)](https://www.youtube.com/watch?v=JyxuEkoYDQk)\n\n\n## Screenshots\n\n![Screenshot](screenshots/pspg-4.3.0-mc-export-111x34.png)\n![Screenshot](screenshots/pspg-4.3.0-mc-111x34.png)\n![Screenshot](screenshots/pspg-4.3.0-foxpro-111x34.png)\n![Screenshot](screenshots/pspg-4.3.0-tao-111x34.png)\n![Screenshot](screenshots/pspg-4.3.0-green-search-111x34.png)\n![Screenshot](screenshots/theme1.gif)\n![Screenshot](screenshots/theme3.gif)\n\n\n## Options\n\n    [pavel@localhost ~]$ pspg --help\n    pspg is a Unix pager designed for table browsing.\n\n    Usage:\n      pspg [OPTION] [file]\n\n    General options:\n      --about                  about authors\n      --help                   show this help\n      -V, --version            show version\n      --info                   show info about libraries and system\n      --direct-color           force direct-color terminal mode\n      -f, --file=FILE          open file\n      -F, --quit-if-one-screen\n                               quit if content is one screen\n      --clipboard-app=NUM      specify app used by copy to clipboard (1, 2, 3, 4)\n      --esc-delay=NUM          specify escape delay in ms (-1 inf, 0 not used, )\n      --interactive            force interactive mode\n      --ignore_file_suffix     don't try to deduce format from file suffix\n      --ni                     not interactive mode (only for csv and query)\n      --no-watch-file          don't watch inotify event of file\n      --no-mouse               don't use own mouse handling\n      --no-progressive-load    don't use progressive data load\n      --no-sigint-search-reset\n                               without reset searching on sigint (CTRL C)\n      --no-sleep               without waits against flickering\n      --no_xterm_mouse_mode    don't use optional xterm mouse mode\n      --only-for-tables        use std pager when content is not table\n      --on-sigint-exit         exit on sigint(CTRL C or Escape)\n      --pgcli-fix              try to fix some pgcli related issues\n      --querystream            read queries from stream forever\n      --quit-on-f3             exit on F3 like mc viewers\n      --rr=ROWNUM              rows reserved for specific purposes\n      --stream                 read input forever\n      -X, --reprint-on-exit    preserve content after exit\n\n    Output format options:\n      -a, --ascii              force ascii\n      -b, --blackwhite         black-white style\n      -s, --style=N            set color style number (0..22)\n      --bold-labels            row, column labels use bold font\n      --bold-cursor            cursor use bold font\n      --border                 type of borders (0..2)\n      --double-header          header separator uses double lines\n      --force-uniborder        replace ascii borders by unicode borders\n      --highlight-odd-rec      highlights odd records (when it is supported by style)\n      --hide-header-line       hides header line (between column names and data)\n      --ignore-short-rows        rows with wrong column numbers are ignored\n      --null=STRING            STRING used instead NULL\n\n    Searching options\n      -g --hlite-search, -G --HILITE-SEARCH\n                               don't highlight lines for searches\n      -i --ignore-case         ignore case in searches that do not contain uppercase\n      -I --IGNORE-CASE         ignore case in all searches\n\n    Interface options:\n      -c, --freezecols=N       freeze N columns (0..9)\n      --less-status-bar        status bar like less pager\n      --line-numbers           show line number column\n      --menu-always            show top bar menu every time\n      --no-bars, --no-commandbar, --no-topbar\n                               don't show bottom, top bar or both\n      --no-cursor              row cursor will be hidden\n      --no-last-row-search     don't use the last pattern when starting a new search\n      --no-scrollbar           don't show scrollbar\n      --no-sound               don't use beep when scroll is not possible\n      --tabular-cursor         cursor is visible only when data has table format\n      --vertical-cursor        show vertical column cursor\n\n    Input format options:\n      --csv                    input stream has csv format\n      --csv-separator          char used as field separator\n      --csv-header [on/off]    specify header line usage\n      --skip-columns-like=\"SPACE SEPARATED STRING LIST\"\n                               columns with substr in name are ignored\n      --csv-trim-width=NUM     trim value after NUM chars\n      --csv-trim-rows=NUM      trim value after NUM rows\n      --tsv                    input stream has tsv format\n\n    On exit options:\n      --on-exit-reset          sends reset terminal sequence \"\\33c\"\n      --on-exit-clean          sends clean terminal sequence \"\\033[2J\"\n      --on-exit-erase-line     sends erase line terminal sequence \"\\33[2K\\r\"\n      --on-exit-sgr0           sends sgr0 terminal sequence \"\\033[0;10m\"\n\n    Watch mode options:\n      -q, --query=QUERY        execute query\n      -w, --watch time         the query (or read file) is repeated every time (sec)\n\n    Connection options:\n      -d, --dbname=DBNAME      database name\n      -h, --host=HOSTNAME      database server host (default: \"local socket\")\n      -p, --port=PORT          database server port (default: \"5432\")\n      -U, --username=USERNAME  database user name\n      -W, --password           force password prompt\n\n    Debug options:\n      --log=FILE               log debug info to file\n      --wait=NUM               wait NUM seconds to allow attach from a debugger\n\npspg shares a lot of key commands with the less pager or the vi editor.\n\nOptions can also be passed within the `PSPG` environment variable. Configuration\nfile is processed first. Options from the `PSPG` variable are processed afterwards\nstep and command line options are processed at the end. One option can\nbe processed multiple times, the last value wins.\n\n## Environment variables\n\n| Name          | Usage                                     |\n|---------------|-------------------------------------------|\n|`PSPG`         | can hold same options like command line   |\n|`PSPG_CONF`    | path to configuration file                |\n|`PSPG_HISTORY` | path to file pspg's readline history file |\n\n## Example of config file\n\nThe default path of config file is `~/.pspgconf`.\n\nThe fields names can be different than from related command line options:\n\n    ascii_menu = false\n    bold_labels = false\n    bold_cursor = false\n    ignore_case = false\n    ignore_lower_case = false\n    no_cursor = false\n    no_sound = false\n    no_mouse = false\n    less_status_bar = false\n    no_highlight_search = false\n    no_highlight_lines = false\n    force_uniborder = false\n    show_rownum = false\n    without_commandbar = false\n    without_topbar = false\n    vertical_cursor = false\n    on_sigint_exit = false\n    no_sigint_search_reset = false\n    double_header = false\n    quit_on_f3 = false\n    pgcli_fix = false\n    xterm_mouse_mode = true\n    show_scrollbar = true\n    menu_always = false\n    empty_string_is_null = true\n    last_row_search = true\n    progressive_load_mode = true\n    highlight_odd_rec = false\n    hide_header_line = false\n    on_exit_reset = false\n    on_exit_clean = false\n    on_exit_erase_line = false\n    on_exit_sgr0 = false\n    direct_color = false\n    theme = 16\n    border_type = 2\n    default_clipboard_format = 0\n    clipboard_app = 0\n    hist_size = 500\n    esc_delay = -1\n\n## Themes\n\n|Code| Name                                  |\n|---:|---------------------------------------|\n|  0 | black \u0026 white                         |\n|  1 | Midnight Commander like               |\n|  2 | FoxPro like                           |\n|  3 | Pdmenu like                           |\n|  4 | White theme                           |\n|  5 | Mutt like                             |\n|  6 | PCFand like                           |\n|  7 | Green theme                           |\n|  8 | Blue theme                            |\n|  9 | Word Perfect like                     |\n| 10 | Low contrast blue theme               |\n| 11 | Dark cyan/black mode                  |\n| 12 | Paradox like                          |\n| 13 | dBase IV retro style                  |\n| 14 | dBase IV retro style (Magenta labels) |\n| 15 | Red white theme                       |\n| 16 | Simple theme                          |\n| 17 | Solarized dark theme                  |\n| 18 | Solarized light theme                 |\n| 19 | Gruvbox light theme                   |\n| 20 | Tao Light theme                       |\n| 21 | FlatWhite theme                       |\n| 22 | Relational pipes theme                |\n| 23 | Paper Color theme                     |\n| 24 | Dracula theme                         |\n\nsee http://okbob.blogspot.cz/2017/07/i-hope-so-every-who-uses-psql-uses-less.html\n\n### Custom themes\n\nThe theme can be customized over base and menu templates referencing the\nbuilt-in themes. The custom theme file should be saved in directory with `pspg`\nconfiguration. The name of this file should be .pspg_theme_xxx. The custom\ntheme can be selected by command line option `--custom-style=name` or by\ncommand `\\ctheme name`.\n\n![Screenshot](screenshots/pspg-5.4.0-custom-theme.png)\n\nExample of a custom theme file (named `.pspg_theme_mc2` (it can be activated by\ncommand `\\ctheme mc2`)):\n\n    template = 1\n    template_menu = 3\n\n    background = black, white\n    data = black, white\n    label = black, white, italic, bold\n    border = #000000, white\n    footer = lightgray, white\n    cursor_data = blue, white, italic, bold, dim, reverse\n    cursor_border = blue, blue , italic, bold, dim, reverse\n    cursor_label = blue, white, italic, bold, dim, reverse\n    cursor_footer = blue, white, italic, bold, dim, reverse\n    cursor_bookmark = red, white, italic, bold, dim, reverse\n    cross_cursor = white, blue, italic, bold\n    cross_cursor_border = brightblue, blue\n    status_bar = black, lightgray\n    title = black, lightgray\n    scrollbar_arrows = black, white\n    scrollbar_background = lightgray, white\n    scrollbar_slider = white, gray\n\nSome keys can be marked by symbol `*`. Marked keys are used for odd records.\n\n    data* = black, lightgray\n    label* = black, lightgray, italic, bold\n    border* = #000000, lightgray\n\n`template` and `template_menu` set fallback values for any keys not specified\nin the custom theme. `template_menu` in particular is currently the only way to\ncustomize the F9 menu appearance.\n\n| key                                   | customizes                                                          |\n|---------------------------------------|---------------------------------------------------------------------|\n| `background`                          | Background color                                                    |\n| `data`                                | Data (non-header or frozen column) text                             |\n| `border`                              | Border color                                                        |\n| `label`                               | Label (header or frozen column) text                                |\n| `row_number`                          | Line numbers                                                        |\n| `record_number`                       |                                                                     |\n| `selected_area`                       |                                                                     |\n| `footer`                              | Results footer (non-tabular e.g. rowcount)                          |\n| `cursor_data`                         | Highlighted data (non-header or frozen column) text                 |\n| `cursor_border`                       | Highlighted border color                                            |\n| `cursor_label`                        | Highlighted label (header or frozen column) text                    |\n| `cursor_row_number`                   | Highlighted line numbers                                            |\n| `cursor_record_number`                |                                                                     |\n| `cursor_selected_area`                |                                                                     |\n| `cursor_footer`                       | Highlighted results footer (non-tabular e.g. rowcount)              |\n| `scrollbar_arrows`                    | Scrollbar up and down arrows                                        |\n| `scrollbar_background`                | Scrollbar \"empty\" background                                        |\n| `scrollbar_slider`                    | Scrollbar slider over the background                                |\n| `scrollbar_active_slider`             | Scrollbar slider grabbed by mouse                                   |\n| `title`                               | Results headline (in psql describe commands)                        |\n| `status_bar`                          | Top query and cursor location information                           |\n| `prompt_bar`                          |                                                                     |\n| `info_bar`                            | Info text (e.g. \"Not found\" when searching)                         |\n| `input_bar`                           | Input prompt and text (e.g. search)                                 |\n| `error_bar`                           |                                                                     |\n| `bookmark`                            |                                                                     |\n| `bookmark_border`                     |                                                                     |\n| `cursor_bookmark`                     |                                                                     |\n| `cross_cursor`                        | Highlighted cell at intersection of horizontal and vertical cursors |\n| `cross_cursor_border`                 | Borders at intersection of horizontal and vertical cursors          |\n| `matched_pattern`                     | Search result match text                                            |\n| `matched_pattern_nohl`                |                                                                     |\n| `matched_line`                        | Line containing search result                                       |\n| `matched_line_border`                 | Borders in search result line                                       |\n| `matched_pattern_cursor`              | Highlighted search result match text                                |\n| `matched_line_vertical_cursor`        | Vertically highlighted search result match text                     |\n| `matched_line_vertical_cursor_border` | Borders of vertically highlighted cell with search result match     |\n| `error`                               |                                                                     |\n\nANSI colors `Black`, `Red`, `Green`, `Brown`, `Blue`, `Magenta`, `Cyan`,\n`LightGray`, `Gray`, `BrightRed`, `BrightGreen`, `Yellow`, `BrightBlue`,\n`BrightMagenta`, `BrightCyan`, `White`, and `Default` will display as your\nterminal emulator configures them. Alternatively, you can specify hex RGB\nvalues `#FF00FF`.\n\nStyles are any combination of: `bold`, `italic`, `underline`, `reverse`,\n`standout`, `dim`.\n\nIf the format of some key is not correct, then this row is ignored. For debugging of\ncustom theme is good to start `pspg` with option `--log`. An information about broken\ndefinitions are stored in log file.\n\n\n## Keyboard commands\n\n| Key(s)                                                                   | Command                                                             |\n|--------------------------------------------------------------------------|---------------------------------------------------------------------|\n| \u003ckbd\u003e0\u003c/kbd\u003e, \u003ckbd\u003e1\u003c/kbd\u003e, \u003ckbd\u003e2\u003c/kbd\u003e, \u003ckbd\u003e3\u003c/kbd\u003e, .., \u003ckbd\u003e9\u003c/kbd\u003e | freeze first N columns                                              |\n| \u003ckbd\u003eKEY_UP\u003c/kbd\u003e, \u003ckbd\u003ek\u003c/kbd\u003e                                          | navigate backward by one line                                       |\n| \u003ckbd\u003eKEY_DOWN\u003c/kbd\u003e, \u003ckbd\u003ej\u003c/kbd\u003e                                        | navigate forward by one line                                        |\n| \u003ckbd\u003eKEY_LEFT\u003c/kbd\u003e, \u003ckbd\u003eh\u003c/kbd\u003e                                        | scroll to left                                                      |\n| \u003ckbd\u003eKEY_RIGHT\u003c/kbd\u003e, \u003ckbd\u003el\u003c/kbd\u003e                                       | scroll to right                                                     |\n| \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eKEY_LEFT\u003c/kbd\u003e                                      | scroll one char left                                                |\n| \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eKEY_RIGHT\u003c/kbd\u003e                                     | scroll one char right                                               |\n| \u003ckbd\u003eShift\u003c/kbd\u003e+\u003ckbd\u003eKEY_LEFT\u003c/kbd\u003e                                     | scroll one column left                                                |\n| \u003ckbd\u003eShift\u003c/kbd\u003e+\u003ckbd\u003eKEY_RIGHT\u003c/kbd\u003e                                    | scroll one column right                                               |\n| \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eHome\u003c/kbd\u003e, \u003ckbd\u003eg\u003c/kbd\u003e                            | go to the start of file                                             |\n| \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eEnd\u003c/kbd\u003e, \u003ckbd\u003eG\u003c/kbd\u003e                             | go to the end of file                                               |\n| \u003ckbd\u003eAlt\u003c/kbd\u003e+\u003ckbd\u003el\u003c/kbd\u003e                                              | go to line number                                                   |\n| \u003ckbd\u003eH\u003c/kbd\u003e                                                             | go to first line of current window                                  |\n| \u003ckbd\u003eM\u003c/kbd\u003e                                                             | go to half of current window                                        |\n| \u003ckbd\u003eL\u003c/kbd\u003e                                                             | go to end of current window                                         |\n| \u003ckbd\u003ePPAGE\u003c/kbd\u003e, \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eb\u003c/kbd\u003e                           | backward one window                                                 |\n| \u003ckbd\u003eNPAGE\u003c/kbd\u003e, \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003ef\u003c/kbd\u003e, \u003ckbd\u003espace\u003c/kbd\u003e         | forward one window                                                  |\n| \u003ckbd\u003eHOME\u003c/kbd\u003e, \u003ckbd\u003e^\u003c/kbd\u003e                                            | go to begin of line, first column                                   |\n| \u003ckbd\u003eEND\u003c/kbd\u003e, \u003ckbd\u003e$\u003c/kbd\u003e                                             | go to end of line, last column                                      |\n| \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003ee\u003c/kbd\u003e                                             | scroll a window down                                                |\n| \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003ey\u003c/kbd\u003e                                             | scroll a window up                                                  |\n| \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003ed\u003c/kbd\u003e                                             | forward a half window                                               |\n| \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eu\u003c/kbd\u003e                                             | backward a half window                                              |\n| \u003ckbd\u003es\u003c/kbd\u003e                                                             | save content to file                                                |\n| \u003ckbd\u003e/\u003c/kbd\u003e                                                             | search for a pattern which will take you to the next occurrence     |\n| \u003ckbd\u003e?\u003c/kbd\u003e                                                             | search for a pattern which will take you to the previous occurrence |\n| \u003ckbd\u003en\u003c/kbd\u003e                                                             | for next match                                                      |\n| \u003ckbd\u003eN\u003c/kbd\u003e                                                             | for next match in reverse direction                                 |\n| \u003ckbd\u003ec\u003c/kbd\u003e                                                             | column search                                                       |\n| \u003ckbd\u003eAlt\u003c/kbd\u003e+\u003ckbd\u003e/\u003c/kbd\u003e                                              | search for a pattern inside selected area                           |\n| \u003ckbd\u003eAlt\u003c/kbd\u003e+\u003ckbd\u003e?\u003c/kbd\u003e                                              | backward search for a pattern inside selected area                  |\n| \u003ckbd\u003eAlt\u003c/kbd\u003e+\u003ckbd\u003ec\u003c/kbd\u003e                                              | switch (on, off) drawing line cursor                                |\n| \u003ckbd\u003eAlt\u003c/kbd\u003e+\u003ckbd\u003em\u003c/kbd\u003e                                              | switch (on, off) own mouse handler                                  |\n| \u003ckbd\u003eAlt\u003c/kbd\u003e+\u003ckbd\u003en\u003c/kbd\u003e                                              | switch (on, off) drawing line numbers                               |\n| \u003ckbd\u003eAlt\u003c/kbd\u003e+\u003ckbd\u003ev\u003c/kbd\u003e, \u003ckbd\u003edouble click\u003c/kbd\u003e on column header    | switch (on, off) drawing column cursor                              |\n| \u003ckbd\u003eMouse button wheel\u003c/kbd\u003e                                            | scroll vertical                                                     |\n| \u003ckbd\u003eAlt\u003c/kbd\u003e+\u003ckbd\u003eMouse button wheel\u003c/kbd\u003e                             | scroll horizontal                                                   |\n| \u003ckbd\u003eF9\u003c/kbd\u003e                                                            | show menu                                                           |\n| \u003ckbd\u003eq\u003c/kbd\u003e, \u003ckbd\u003eF10\u003c/kbd\u003e, \u003ckbd\u003eEsc\u003c/kbd\u003e \u003ckbd\u003e0\u003c/kbd\u003e                | quit                                                                |\n| \u003ckbd\u003eAlt\u003c/kbd\u003e+\u003ckbd\u003eq\u003c/kbd\u003e                                              | quit and print raw (unformatted) content                            |\n| \u003ckbd\u003eAlt\u003c/kbd\u003e+\u003ckbd\u003ek\u003c/kbd\u003e, \u003ckbd\u003eAlt\u003c/kbd\u003e+\u003ckbd\u003edouble click\u003c/kbd\u003e      | switch bookmark                                                     |\n| \u003ckbd\u003eAlt\u003c/kbd\u003e+\u003ckbd\u003ej\u003c/kbd\u003e                                              | go to next bookmark                                                 |\n| \u003ckbd\u003eAlt\u003c/kbd\u003e+\u003ckbd\u003ei\u003c/kbd\u003e                                              | go to previous bookmark                                             |\n| \u003ckbd\u003eAlt\u003c/kbd\u003e+\u003ckbd\u003eo\u003c/kbd\u003e                                              | flush bookmarks                                                     |\n| \u003ckbd\u003ea\u003c/kbd\u003e                                                             | sort ascendent                                                      |\n| \u003ckbd\u003ed\u003c/kbd\u003e                                                             | sort descendent                                                     |\n| \u003ckbd\u003eu\u003c/kbd\u003e                                                             | unsorted (sorted in origin order)                                   |\n| \u003ckbd\u003eSpace\u003c/kbd\u003e                                                         | stop/continue in watch mode                                         |\n| \u003ckbd\u003eR\u003c/kbd\u003e                                                             | Repaint screen and refresh input file                               |\n| \u003ckbd\u003eIns\u003c/kbd\u003e                                                           | export row, column or cell to default target                        |\n| \u003ckbd\u003eshift\u003c/kbd\u003e+\u003ckbd\u003ecursor up, down\u003c/kbd\u003e                              | define row range                                                    |\n| \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eShift\u003c/kbd\u003e+\u003ckbd\u003ecursor left, right\u003c/kbd\u003e           | define column range                                                 |\n| \u003ckbd\u003eF3\u003c/kbd\u003e                                                            | start/finish of selection rows                                      |\n| \u003ckbd\u003eShift\u003c/kbd\u003e+\u003ckbd\u003eF3\u003c/kbd\u003e                                           | start/finish of selection block                                     |\n| \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003edrag mouse\u003c/kbd\u003e                                    | defines rows selection, on column header defines column selection   |\n| \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eo\u003c/kbd\u003e                                             | show primary screen, press any key to return to pager again         |\n| \u003ckbd\u003e%\u003c/kbd\u003e, \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003ea\u003c/kbd\u003e                               | select all                                                          |\n\n## Backslash commands\n\n| Command                                                      | Description                |\n|--------------------------------------------------------------|----------------------------|\n| `\\N`                                                         | go to line number          |\n| `\\+N`                                                        | go to N lines forward      |\n| `\\-N`                                                        | go to N lines backward     |\n| `\\N+`                                                        | go to line number          |\n| `\\N-`                                                        | go to line number from end |\n| `\\theme N`                                                   | set theme number           |\n| `\\copy [all\\|selected] [nullstr \"str\"] [csv\\|tsv\\|insert\\|text\\|pipesep\\|sqlvalues]` | copy data to clipboard     |\n| `\\save [all\\|selected] [nullstr \"str\"] [csv\\|tsv\\|insert\\|text\\|pipesep\\|sqlvalues]` | copy data to clipboard     |\n| `\\order [N\\|column name]`                                     | sort by column             |\n| `\\orderd [N\\|column name]`                                    | desc sort by column        |\n| `\\sort [N\\|column name]`                                      | sort by column             |\n| `\\sortd [N\\|column name]`                                     | desc sort by column        |\n| `\\dsort [N\\|column name]`                                     | desc sort by column (alias)|\n| `\\rsort [N\\|column name]`                                     | desc sort by column (alias)|\n| `\\asc [N\\|column name]`                                       | sort by column (alias)     |\n| `\\desc [N\\|column name]`                                      | desc sort by column (alias)|\n| `\\search [back] [selected] [column name] [string\\|\"string\"]`  | search string in data      |\n\n\nThe output can be redirected to any command when the name starts with pipe symbol:\n\n    \\copy csv | less\n\n## Ending\n\nThe pager can be ended by pressing keys \u003ckbd\u003eq\u003c/kbd\u003e or \u003ckbd\u003eF10\u003c/kbd\u003e or \u003ckbd\u003eEsc\u003c/kbd\u003e \u003ckbd\u003e0\u003c/kbd\u003e.\nWith option `--on-sigint-exit` then the pager is closed by pressing keys \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003ec\u003c/kbd\u003e\nor \u003ckbd\u003eEsc\u003c/kbd\u003e \u003ckbd\u003eEsc\u003c/kbd\u003e.\n\n## Use \u003ckbd\u003eEscape\u003c/kbd\u003e, key instead \u003ckey\u003eAlt\u003c/key\u003e + \u003ckey\u003ekey\u003c/key\u003e\n\npspg supports a possibility to use a sequence of keys \u003ckbd\u003eEsc\u003c/kbd\u003e, \u003ckbd\u003ekey\u003c/kbd\u003e instead an\ncombination of \u003ckbd\u003eAlt\u003c/kbd\u003e+\u003ckbd\u003ekey\u003c/kbd\u003e. The interval between pressing \u003ckbd\u003eEsc\u003c/kbd\u003e and\n\u003ckbd\u003ekey\u003c/kbd\u003e is limited by interval specified by option `esc-delay` or by configuration's\noption `esc_delay`. This is max delay time in ms. After this interval, the single pressing \u003ckbd\u003eEsc\u003c/kbd\u003e\nis interpreted as `Escape`. -1 meas unlimited, 0 disables this feature.\n\n## Column search\n\nColumn search is case insensitive every time. Searched column is marked by vertical cursor.\nLast non empty string searching pattern is used when current searching pattern is empty string.\nSearching is starting after visible vertical column or on first visible not freezed columns (after\nsome horizontal scrolling) or on first column. After last column searching starts from first again.\n\n\n## Export \u0026 Clipboard\n\nFor clipboard support the clipboard application should be installed: 1. wl-clipboard (Wayland),\n2. xclip (xwindows), 3. pbcopy (MacOS) or 4. clip.exe (WSL2).\n\n`pspg` try to translate unicode symbol '∅' to NULL every time. If you don't use special setting\nby `\\pset null ...`, then `psql` displays empty string instead NULL. `pspg` hasn't any special\ndetection (in export routines) for this case. You should to check and enable or disable menu\nitem `Empty string is NULL`.\n\n`pspg` has automatic detection of clipboard application. Unfortunately, this detection should\nnot to work for same cases. You can specify the application by specify number (1,2,3,4) to\n`--clipboard-app` option.\n\nFormats make a difference! pspg copies records in CSV format by default, which uses comma\nseparators and **trims initial and trailing whitespace**. Use \"formatted text\" to copy query output\nexactly, or choose one of the other available options.\n\n\n## Status line description\n\n* `V: [d/d d..d]` - vertical cursor: (column number)/(columns) (char positions from) .. (char positions to)\n* `FC: d` - freezed columns length in chars\n* `C: d..d/d` - unfreezed visible data in chars (from .. to)/(total)\n* `L:[d + d  d/d]` - lines (number of first visible line) + (number of line of display), (current line)/(lines)\n* `d%` - percent of already displayed data\n\n\n## Usage as csv viewer\n\nIt works well with miller http://johnkerl.org/miller/doc/index.html\n\u003cpre\u003e\nmlr --icsv --opprint --barred put '' obce.csv | pspg --force-uniborder\n\u003c/pre\u003e\n\nNew version has integrated csv support - just use `--csv` option.\n\nIt can be integrated into \u003ccode\u003emc\u003c/code\u003e\n\n* copy file from `/etc/mc/mc.ext` to your `~/.config/mc directory`\n* insert there\n\n\u003cpre\u003e\n\n\n##csv\n\nregex/\\.csv\n    View=pspg -f %f --csv\n\u003c/pre\u003e\n\n* restart \u003ccode\u003emc\u003c/code\u003e\n\n\n## Known issues\n\n* When you use `pspg` on Cygwin, then some temporary freezing of scrolling was reported\n  In this case, please, use an option `--no-sleep`. I see slow scrolling (via scrollbar)\n  inside konsole (KDE terminal). The option `--no-sleep` helps too.\n\n\n## Usage in watch mode\n\nThe result of query can be refreshed every n seconds. `pspg` remembers cursor row,\npossible vertical cursor, possible ordering. The refreshing should be paused by pressing\n\u003ckbd\u003espace\u003c/kbd\u003e key. Repeated pressing of this key enables refreshing again.\n\n`pspg` uses inotify API when it is available, and when input file is changed, then\n`pspg` reread file immediately. This behave can be disabled by option `--no-watch-file`\nor by specification watch time by option `--watch`.\n\n\n## Streaming modes\n\n`pspg` can read a continuous stream of tabular data from pipe, named pipe or from file\n(with an option `--stream` or it can read a stream of queries from pipe or from file\n(with an option `--querystream`). In stream mode, only data in table format can be\nprocessed, because `pspg` uses empty line as separator between tables.\n\nThe query stream mode is an sequence of SQL statements separated by char GS (Group\nseparator - 0x1D on separated line.\n\n\u003cpre\u003e\npavel@localhost ~]$ cat \u003c /dev/pts/3 \u003e ~/pipe\nselect 10\n^]\nselect 20\n^]\nselect *\nfrom\npg_class\n^]\n\u003c/pre\u003e\n\n\n## Recommended psql configuration\n\nyou should to add to your profile:\n\u003cpre\u003e\n#for Postgres 10 and older\nexport PAGER=\"pspg\"\n\n#for postgres 11 and newer\nexport PSQL_PAGER=\"pspg\"\n\n#or \"\\setenv PAGER pspg\" to .psqlrc\n\u003c/pre\u003e\n\nand \u003ccode\u003e.psqlrc\u003c/code\u003e\n\n\u003cpre\u003e\n\\set QUIET 1\n\\pset linestyle unicode\n\\pset border 2\n\\pset null ∅\n\\unset QUIET\n\u003c/pre\u003e\n\nsome possible configuration:\n\u003cpre\u003e\n-- Switch pagers with :x and :xx commands\n\\set x '\\\\setenv PAGER less'\n\\set xx '\\\\setenv PAGER \\'pspg -bX --no-mouse\\''\n:xx\n\u003c/pre\u003e\n\n`LC_CTYPE` should be correct. Mainly when you use unicode borders.\nncurses doesn't display unicode borders (produced by `psql`) without\ncorrect setting of this variable. Is possible to check a value 'C.UTF8'.\n\n\n## Attention\n\nWhen you use a option `--only-for-tables`, then\n\n* set `PAGER` to `pspg` and `PSQL_PAGER` to `less` or\n* set `PAGER` to `less` and `PSQL_PAGER` to `pspg`\n\n\n## MySQL usage\n\n\u003cpre\u003e\nMariaDB [sakila]\u003e pager pspg -s 14 -X --force-uniborder --quit-if-one-screen\nPAGER set to 'pspg -s 14 -X --force-uniborder --quit-if-one-screen'\nMariaDB [sakila]\u003e select now();\nMariaDB [sakila]\u003e select * from nicer_but_slower_film_list limit 100;\n\u003c/pre\u003e\n\n\n## SQLite\n\nSQLite native client doesn't produce well formatted output, but can be forced\nto generate CSV format - and this format is well readable for `pspg`\n\n    sqlite3 -csv -header testdb.db 'select * from foo2' | pspg --csv --csv-header=on --double-header\n\n\n\n## pgcli\n\n[pgcli](https://github.com/dbcli/pgcli/) needs the following configuration options (`~/.config/pgcli/config`):\n\n    pager = /usr/bin/pspg --csv --rr=2 --quit-if-one-screen --ignore-case --csv-header on --pgcli-fix\n    table_format = csv\n\n\nOlder version of pgcli had very slow output in tabular format. An workaround was using csv format. This should not be necessary on current versions when the performance issue was fixed.\nAn option `--pgcli-fix` fixed import of partially broken csv format generated by `pgcli`. Modern version of `pgcli` doesn't need csv format,\nand doesn't need `--pgcli-fix` option.\n\n    pager = /usr/bin/pspg --rr=2 --quit-if-one-screen --ignore-case\n\n\n## sqlcl\n\nAs `sqlcl` doesn't currently support a pager option directly, you can either use a tool like [qsh](https://github.com/muhmud/qsh) to work around this issue, or use the [pspg.sql](https://github.com/okbob/pspg/blob/master/scripts/sqlcl/pspg.sql) script from this repo.\n\nTo use the script, start `sqlcl` as shown below (it's important to pass in the details of your current tty):\n\n    $ TTY=$(tty) sqlcl system/system @/path/to/pspg.sql\n\nYou can now have the results of a query sent to `pspg` like this:\n\n    SQL\u003e pspg select * from user_tables;\n\n## nushell\n\nThe `pspg` supports default `table_mode`: `rounded` and `table_mode`: `heavy`.\n\nThe conversion to csv can be used too.\n\n    sys | get cpu | to csv | pspg --csv\n\n\nNote: `footer_mode` should be disabled\n\nnushell configuration:\n\n    $env.config.footer_mode = never\n    $env.config.table.header_on_separator = false\n    $env.config.ls.clickable_links = false\n    $env.config.table.mode = rounded\n\n## Note - mouse\n\npspg try to use xterm mouse mode 1002, when terminal and ncurses are not too antique. If there\nare problems with usage - unwanted visual artefacts when you move with mouse when some mouse\nbutton is pressed, then 1. please, report issue (please, attach log file), 2. use an option\n`--no-xterm-mouse-mode` and `pspg` will not try to activate this mode.\n\n## Note - true color themes on KDE konsole terminal\n\nOn my Fedora this terminal doesn't correctly display true color themes. The basic problem\nis in default `TERM` setting, that is `xterm-256color`. Unfortunately, the `konsole` terminal\nis not fully compatible with `xterm`, and doesn't allow color changing. You can force direct\ncolors by using the option `--direct-color` or by setting `TERM=xterm-direct`. Second option\nis more correct setting of `TERM` variable to `konsole-256color`. In this case the `pspg` will\nmap the true rgb colors to supported 256 colors.\n\n## Note - compilation issue\n\nSome linker issues can be fixed by:\n\u003cpre\u003e\nI changed\ngcc -lncursesw pager.c -o pspg -ggdb\nto\ngcc pager.c -o pspg -ggdb -lncursesw\n\u003c/pre\u003e\n\nIf you want to use `pspg` as Postgres client, then you need run\n`configure --with-postgresql=yes`. On Fedora with own Postgres build\nI had to install `openssl-devel` package and I had to set\n`export PKG_CONFIG_PATH=\"/usr/local/pgsql/master/lib/pkgconfig/\"`.\n\nOn FreeBsd you should to use `gmake` instead `make`.\n\n## Note - Installation details\n\nWhen you compile code from source, run ./configure first. Sometimes ./autogen.sh first\n\nIf you would to display UTF-8 characters, then `pspg` should be linked with `ncursesw`\nlibrary. UTF-8 characters are displayed badly when library `ncursesw` is used. You can\nsee broken characters with incorrect locale setting too.\n\nYou can check wide chars support by `pspg --version`. Row `ncurses with wide char support`\nis expected. Re-run `configure` with `--with-ncursesw` option. When this command fails check\nif development package for ncursesw library is installed.\n\n\n### Homebrew (for Linux \u0026 MacOS)\n\n    # brew install pspg\n\nYou can compile easily `pspg` without `brew`, but you need `gnu readline` library. MacOS uses\nby default readline emulated over libedit, but `pspg` requires full gnu readline library.\n\n    LDFLAGS=\"-L/usr/local/opt/readline/lib\" CPPFLAGS=\"-I/usr/local/opt/readline/include\" ./configure\n    LDFLAGS=\"-L/usr/local/opt/readline/lib\" CPPFLAGS=\"-I/usr/local/opt/readline/include\" make\n\n### Debian\n\n    # apt-cache search pspg\n    # apt-get install pspg\n\n\n### Fedora (28 and later)\n\n    # dnf install pspg\n\n\n### RPM (CentOS/openSUSE/…)\nThe pspg is available from community repository https://yum.postgresql.org/packages.php\n\n\n### Alpine Linux\n\n    # apk add pspg\n\n\n### Gentoo\n\n    # emerge -av dev-db/pspg\n\n\n### Arch Linux\n\nThe Arch User Repository contains two versions:\n\n* [pspg](https://aur.archlinux.org/packages/pspg/) is a fixed release.\n* [pspg-git](https://aur.archlinux.org/packages/pspg-git/) tracks the `master` branch.\n\nUse the AUR helper of your choice or git and `makepkg` to install pspg.\n\n\n### FreeBSD\n\n    # pkg install pspg\n\n### OpenBSD\n\n    # pkg_add pspg\n\n[More about it](https://fluca1978.github.io/2021/10/28/pspgOpenBSD.html)\n\n### Using MacPorts (MacOS only)\n\n    # port install pspg\n\n### MS Windows\n\n`pspg` can be simply used on MS Windows by using wsl2. I tested it, and it is working without problems.\n\n* In terminal execute `wsl --install -d Ubuntu-22.04`\n\n* In terminal open Ubuntu session\n\n```\nsudo apt-get update\nsudo apt-get install pspg\nsudo apt-get install postgresql postgresql-contrib\n\n# set password for user postgres\nsudo passwd postgres\nsu - postgres\npsql postgres\n\u003e\u003e create role pavel login;\n\\q\nexit\ntouch ~/.psqlrc\nmcedit .psqlrc\n\\pset linestyle unicode\n\\pset border 2\n\\setenv PSQL_PAGER 'pspg -b -X'\n# press F2 and F10\npsql postgres\n```\n\nthere is not any difference from installation and work on Ubuntu (Debian)\n\n`pspg` is not ported to MS Windows yet. There is the dependency on ncurses and correctly (fully)\nimplemented function `newterm` (`pdcurses` does this only on Unix platforms). It can work\nwith WSL2 maybe (I didn't test it). An alternative can be using `less` pager, that is ported\nto some MS Win enviroments. `less` depends on `termcap`, and it is little bit more portable\nthan `pspg` (`termcal` is low layer of ncurses). `less` supports fixed rows and with `--chop-long-lines`\noption or just `-S` can be used as pager for `pspg`.\n\n    export PSQL_PAGER=\"less --chop-long-lines --header 1\"\n\n### Solaris\n\nThere are few issues requires manual code changes for successful compilation - we successfully\ntested `pspg`, but although `pspg` was linked with ncursesw libraries, the utf8 encoding support\ndidn't work fully correctly - probably due some issues in `libc` library. There are problems with\nchars encoded to 3bytes - unicode borders, .. Two bytes unicode chars should be displayed well.\n\nYou can use `pspg` with usual accented chars, but unicode borders should not be used. Replacement\nascii borders by special borders chars (by ncurses technology) works well - looks on `Options|Force unicode borders`\noption.\n\n* Solaris `make` doesn't support conditional statements - should be removed So, remove unsupported\n  functionality from `Makefile` (`ifdef`,`endif`), replace `-include` by `include` first.\n\n* After running `configure` remove link on `termcap` library from `config.make`. It is garbage\n  produced by `readline` automake script. Combination with `ncurses` libraries makes some\n  linking issues.\n\n\n#### builtin libraries\n\n    export CURSES_CFLAGS=\"-I/usr/include/ncurses/\"\n    export PANEL_LIBS=\"-lpanelw\"\n    ./configure\n\n\n#### OpenCSW development\n\n    export CFLAGS=\"-m64 -I/opt/csw/include\"\n    export LDFLAGS=\"-L/opt/csw/lib/64 -R/opt/csw/lib/64\"\n    export PKG_CONFIG_PATH=\"/opt/csw/lib/64/pkgconfig\"\n    ./configure\n\n\n## Possible ToDo\n\n* Store data in some column format (now data are stored like array of rows). With this change can\n  be possible to operate over columns - hide columns, change width, cyclic iteration over columns,\n  change order of columns, mark columns and export only selected columns (selected rows).\n\n* Replace printing document directly to ncurses window by some smarter structure. Internally\n  there are lot of checks and fixes to support complex dynamic layout. The possibly views should\n  to remember first row, last row, current row. Now, these data are in global variables or in\n  DataDesc and ScrDesc structures.\n\n## st_menu\n\nThis project uses st_menu library - implementation of CUA menubar and pulldown menu for ncurses\nhttps://github.com/okbob/ncurses-st-menu\n\n\n## Note\n\nIf you like it, send a postcard from your home country to my address, please:\n\n    Pavel Stehule\n    Skalice 12\n    256 01 Benesov u Prahy\n    Czech Republic\n\n\nI invite any questions, comments, bug reports, patches on mail address pavel.stehule@gmail.com\n","funding_links":[],"categories":["C","Integrations","Outils d'administration (et conception parfois) de base de données","c","GUI","Other","CLI"],"sub_categories":["Docker et conteneurs"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokbob%2Fpspg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fokbob%2Fpspg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokbob%2Fpspg/lists"}