Skip to content

Bash script to automate startup of PSQL and the PSPG pager under TMUX such that they are connected via a named pipe.

License

Notifications You must be signed in to change notification settings

shawn61cp/xpsql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

xpsql

Bash script to automate startup of PSQL and PSPG connected via a named pipe under TMUX

Introduction

There exists a wonderful pager PSPG developed for PostgreSQL. It is useful for other things as well.

One of its fantastic features is the ability to continuously read input from a named pipe. So, if you direct the query output from PSQL to this pipe, you have the ability to see your data and work with queries etc at the same time.

I like TMUX for text windowing and so I wrote this script to automate the creation of a pane for data display, starting PSPG in this pane, starting PSQL in the original pane, and setting both up for communication via a named pipe.

Screenshot. Custom colored prompts are not provided by this script. Screenshot

Prerequisites

  • Packages needed
    • postgresql-client
    • pspg
    • tmux

Installation

  • Download the xpsql script from this repository to a location of your choice, preferably somewhere along your PATH. This example will use /$HOME/.local/bin but you could install it system-wide by placing it for instance in /usr/local/bin.
  • Make the script executable and create two symlinks to the script in the same location.
    • cd $HOME/.local/bin
    • chmod 755 xpsql
    • ln -s xpsql xpsqlv
    • ln -s xpsql xpsqlh
  • In your home directory create the named pipe. If you have installed this system-wide, any user who uses the script will need to do this step (only once).
    • cd $HOME
    • mkfifo psql1

Usage

Enter xpsql -h for usage/help.

Run xpsqlv (in a TMUX window) to produce panes that are vertically stacked. Run xpsqlh to produce panes that are placed horizontally side-by-side. xpsql by itself defaults to vertical stacking.

In both cases follow the command with arguments just as you would for PSQL. When you exit PSQL, the created pane along with the PSPG instance will be destroyed.

NOTE: PSPG will appear unresposive until the first time some output is sent from PSQL.

About

Bash script to automate startup of PSQL and the PSPG pager under TMUX such that they are connected via a named pipe.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages