Skip to content

Conversation

@devadathanmb
Copy link
Owner

@devadathanmb devadathanmb commented Jan 31, 2026

Description

Adds support for displaying transaction status in the prompt via the \T escape sequence, similar to psql's %x

Behavior:

  • * — inside a valid transaction block
  • ! — inside a failed transaction block
  • ? — connection is closed/indeterminate
  • (empty) — idle, not in a transaction

Example usage in ~/.config/pgcli/config:

prompt = '\u@\h:\d>\T '

This produces prompts like (as shown in the attached screenshot below):

user@localhost:mydb>  SELECT 1;      -- idle

user@localhost:mydb>* BEGIN;         -- in transaction

user@localhost:mydb>! ...            -- failed transaction

user@localhost:mydb>? ...            -- if connection is closed
image image

NOTE: Uses \T instead of \x to avoid conflicts with ANSI escape sequences (\x1b) processing done in the codebase.

Checklist

  • I've added this contribution to the changelog.rst.
  • I've added my name to the AUTHORS file (or it's already there).
  • I installed pre-commit hooks (pip install pre-commit && pre-commit install).
  • Please squash merge this pull request (uncheck if you'd like us to merge as multiple commits)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant