command line - How to customise the PostgreSQL/psql prompt? -


How can I customize the prompt in the PostgreSQL command line tool psql (ideally in each user's start-up script) ?

Specifically, I would like to be able to change it, while still the character has been added which indicates that the command is multi-line (e.g., = , - , ', etc.).

I am running Ubuntu 10.04 (Lucid), PostgreSQL 8.4.4.

You can definitely make a prompt

Documentation:

Prompts that psql problems can be customized according to your preference. PROMPT1, PROMPT2 and PROMPT3 have three variable strings and special escape sequences that describe the look of the prompt. Prompt 1 is a common prompt that is issued when psql requests a new command. When more input is expected during the command input, signal 2 is issued because the command was not ended with a semicolon or no bid was closed. Prompt 3 is issued when you run the SQL COPY command and you expect to type in the row values ​​on the terminal.

If you want to set the signal on a per user basis, you can add the \ Set command to the user's .psqlrc file.

Then, your $ HOME / .psqlrc will be something like this:

  \ PROMPT1 set '(% n @% M:% & gt;)% `date + % H:% M:% S` [% /] \ n% x% # ' 

Comments