Skip to content

Instantly share code, notes, and snippets.

@bootandy
Last active October 6, 2022 16:18
Show Gist options
  • Save bootandy/cb9376c669c14a25d5e76ab84bb083fe to your computer and use it in GitHub Desktop.
Save bootandy/cb9376c669c14a25d5e76ab84bb083fe to your computer and use it in GitHub Desktop.
PSQLRC file with colors
-- prompts:
-- From: select inet_server_addr()
select case
when inet_server_addr()='10.0.0.61' then '%[%033[1;35m%]' -- red
when inet_server_addr()='10.0.0.24' then '%[%033[1;31m%]' -- purp
else '[%037[1m%]' -- cyan
end as col \gset
\set PROMPT2 '[more] %R > '
\set PROMPT1 :col'%M@%/%R%[%033[0m%]%# '
-- Make nulls distinc
\pset null '[NULL]'
-- Verbose error reports.
\set VERBOSITY verbose
-- Use a separate history file per-database.
\set HISTFILE ~/.psql_history- :DBNAME
-- If a command is run more than once in a row, only store it once in the
-- history.
\set HISTCONTROL ignoredups
-- Autocomplete keywords (like SELECT) in upper-case, even if you started
-- typing them in lower case.
\set COMP_KEYWORD_CASE upper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment