invisible-database.patch
application/octet-stream
Filename: invisible-database.patch
Type: application/octet-stream
Part: 0
Message:
Invisible PROMPT2
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/bin/psql/prompt.c | 9 | 0 |
diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c
index 195192a95d..eb8953aec0 100644
--- a/src/bin/psql/prompt.c
+++ b/src/bin/psql/prompt.c
@@ -39,6 +39,7 @@
* %n - database user name
* %/ - current database
* %~ - like %/ but "~" when database name equals user name
+ * %w - whitespace of the same width as the current database
* %# - "#" if superuser, ">" otherwise
* %R - in prompt1 normally =, or ^ if single line mode,
* or a ! if session is not connected to a database;
@@ -123,6 +124,14 @@ get_prompt(promptStatus_t status, ConditionalStack cstack)
strlcpy(buf, PQdb(pset.db), sizeof(buf));
}
break;
+ case 'w':
+ if (pset.db)
+ {
+ size_t len = strlen(PQdb(pset.db));
+
+ memset(buf, ' ', Min(len, sizeof(buf) - 1));
+ }
+ break;
/* DB server hostname (long/short) */
case 'M':