Customizing Your PostgreSQL Prompt: How to Set a Colorful and Eye-Catching psql Prompt
byKishore Uppala-
0
The psql interactive command line prompt can be customized through the psqlrc file, which comes in three variations:
The system-wide startup file, called psqlrc, can be found in the installation's "system configuration" directory. The directory can be identified by running pg_config --sysconfdir, and its name can be set explicitly through the PGSYSCONFDIR environment variable.
The user's personal startup file, named .psqlrc, can be found in the user's home directory. On Windows, the personal startup file is named %APPDATA%\postgresql\ psqlrc.conf due to the lack of a home directory concept. The location of the user's startup file can be set explicitly through the PSQLRC environment variable.
Both the system-wide startup file and the user's personal startup file can be made psql-version-specific by appending a dash and the PostgreSQL major or minor release number to the file name. For example, the user's startup file for PostgreSQL 9.2 or 9.2.5 would be ~/.psqlrc-9.2 or ~/.psqlrc-9.2.5.
Prompting settings:
%MThe full host name (with domain name) of the database server
%mThe host name of the database server, truncated at the first dot
%>The port number at which the database server is listening.
%n The database session username.
%/ The name of the current database.
Colors
Please find the below values for various colours:
32 for green
33 for yellow
34 for blue
35 for magenta
36 for cyan
37 for white
1;31;40 red
By default, the psqlrc file displays welcome messages and various
informational outputs after being edited. To hide these, you can set the
QUIET flag at the beginning and end of the psql file.
The purpose of sharing the content on this website is to Educate. The author/owner of the content do not warrant that the information provided on this website is fully complete and shall not be responsible for any errors or omissions.The author/owner shall have neither liability nor responsibility to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the contents of this website. So, use the content of this website at your own risk.
This content has been shared under Educational And Non-Profit Purposes Only. No Copyright Infringement Intended, All Rights Reserved to the Actual Owner.
For Copyright Content Removal Please Contact us by Email at besttechreads[at]gmail.com