-
Notifications
You must be signed in to change notification settings - Fork 579
Description
pgcli currently shows transaction status in the bottom bar but doesn't support displaying it in the prompt. psql supports this via the %x escape sequence in prompt configuration.
psql behavior:
In psql, you can include transaction status directly in your prompt like:
\set PROMPT1 '%n@%/%x%# 'The %x escape shows:
- Empty string when not in a transaction
*when in a transaction block!when in a failed transaction block?when transaction state is indeterminate
Example prompts:
user@mydb # SELECT 1; -- no transaction
user@mydb* # SELECT 1; -- in transaction
user@mydb! # SELECT 1; -- failed transaction
While the bottom status bar does show this info, having it in the prompt is useful when reviewing scrollback or terminal recordings, and it's what many users are accustomed to from psql. Transactions are core to database work, so prompt-level visibility helps catch mistakes like forgetting you're in a transaction block.
For reference, this behavior is documented in the psql prompt escape sequences: %x transaction status indicator — https://www.postgresql.org/docs/current/app-psql.html#APP-PSQL-PROMPTING
If this is something the maintainers are open to, I'm happy to contribute a PR. Thanks.