Pgcli and Tmux: The Perfect Workflow for PostgreSQL

The query runs fast. The logs stream by. Your database shell hums inside a tmux pane, pgcli’s syntax highlighting painting the SQL in sharp color. Nothing slows you down.

Pgcli and tmux make a lethal pairing for anyone who lives inside PostgreSQL. Pgcli is a modern PostgreSQL CLI with autocompletion, syntax highlighting, and smart tabular display. Tmux is a terminal multiplexer that lets you split, detach, and persist sessions. Combined, they give you a high‑efficiency, keyboard‑driven workflow with zero context switching.

Install pgcli with:

pip install pgcli

Connect to your database:

pgcli -h localhost -u postgres mydb

Install tmux on macOS:

brew install tmux

Start tmux:

tmux

Split your session:

Ctrl+b %
Ctrl+b "

In one pane, run pgcli for your production database. In another, run staging. Add a third for psql logs or monitoring. Move between panes instantly with Ctrl+b plus arrow keys. Detach from the entire environment with Ctrl+b d—your queries keep running in the background. Reattach later with:

tmux attach

With this setup you reduce friction. You keep context loaded in memory—both yours and the machine’s. Queries execute faster when you waste no time switching tools. Tmux keeps your environment alive over SSH drops. Pgcli makes every SQL statement cleaner and more readable.

Integrate this with your deployment pipelines, incident response flows, or analytics sessions. Your workflow is now portable, reliable, and easy to share.

Run pgcli in tmux and feel the latency between thought and action disappear. Try it today in a live PostgreSQL setup at hoop.dev and see it working in minutes.