Created
August 8, 2016 03:00
-
-
Save glebec/35b655857d2c528b811c2115de1b19fa to your computer and use it in GitHub Desktop.
.psqlrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\set QUIET 1 | |
\set VERBOSITY verbose | |
\set COMP_KEYWORD_CASE upper | |
\timing | |
\x auto | |
\pset linestyle unicode | |
\pset border 2 | |
\pset format wrapped | |
\pset null '␀' | |
\set PROMPT1 '\n%[%033[1;34;40m%]psql %[%033[;30;45m%] %M:%> %[%033[;35;40m%] %[%033[36m%]%n %# %[%033[35m%]%~ %[%033[37m%]%x%[%033[;30;49m%]%[%033[0m%] ' | |
\set PROMPT2 '%[%033[1;34;40m%]psql %[%033[35m%]%R% %[%033[;30;49m%]%[%033[0m%] ' | |
\unset QUIET | |
/* psql escape codes: | |
%M - full host + domain for db server, or [local] (if over Unix socket), or [local:/dir/name] | |
%m - host name of the db server, truncated at the first dot, or [local] (if over Unix socket) | |
%> - port where db server is listening | |
%n - database session user name (changes based on SET SESSION AUTHORIZATION) | |
%/ - current database name | |
%~ - like %/ but the output is ~ if the database is the default | |
%# - # if user is superuser, else > (changes based on SET SESSION AUTHORIZATION) | |
%R - in prompt 1: = (normal), ^ (single-line mode), ! (disconnected) | |
%R - in prompt 2: - (more input expected), * (in a comment), ' or " or $ (inside a string) | |
%x - Transaction status: an empty string when not in a transaction block, or * when in a transaction block, or ! when in a failed transaction block, or ? when the transaction state is indeterminate (for example, because there is no connection). | |
*/ | |
/* ANSI control sequences http://www.termsys.demon.co.uk/vtansi.htm | |
Display Attribute FG / BG Color | |
0 Reset ALL 30 / 40 Black | |
1 Bright 31 / 41 Red | |
2 Dim 32 / 42 Green | |
4 Underscore 33 / 43 Yellow | |
5 Blink 34 / 44 Blue | |
7 Reverse 35 / 45 Magenta | |
8 Hidden 36 / 46 Cyan | |
37 / 47 White | |
39 / 49 Default | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add to
~/.psqlrc
. NOTE: this custom prompt assumes you use a powerline-patched font.