I have been gradually tweaking my psqlrc to share key database information when I connect. One example uses conditional color and emoji indicators for active connections; another post describes my plans for a blog post about customizing the broader psql experience.
I use a CASE expression on active_connections from db_info to choose red above 50 connections, yellow above 20, and green otherwise.
In each color branch, I display active_connections - 8 alongside the “Active Connections” label.
I described the coloring as changing when connections are over 100, while the SQL I showed uses thresholds of 50 and 20.
I was working on a crazy blog post to customize a psql setup with psqlrc.
I called the linked item a great teaser: https://t.co/bT22mAkRVj
I use psqlrc to shape my interactive Postgres experience, and I have asked others to share settings and ideas.
I estimated that 90% of the psqlrc setups people shared were some version of a three-line setting for displaying nulls as 👻.
I said, “I'm all for clarity on nulls,” and asked what else people have in their psqlrc setups.
\set QUIET on
\pset null 👻
\set QUIET off
I asked, “What's folks favorite setting they have in their psqlrc?”
On vacation that week, mostly with no internet, I spent free downtime updating my psqlrc.
I had a vision for updating my psqlrc, but said it was “unclear if I can pull it off.”
I lost 30 minutes troubleshooting because builds with libedit not readline, and color highlighting wasn't appearing.
I joked, “If my psql isn't pretty do I even Postgres?”