PostgreSQL

psql 설정파일(.psqlrc) 설정

bedbmsguru 2020. 3. 16. 17:04

1. psql 의 prompt 설정 하기

 

--사용자의 홈디렉토리에서 설정할 것

vi ~/.psqlrc

 

 

\set PROMPT1 '%M:%> %n@%/%R%#%x '

 

  • %M 서버 hostname
  • %> DB port
  • %n session username
  • %/  current database
  • %R  whether you’re in single-line mode (^) or disconnected (!) but is normally =
  • %# refers to whether you’re a superuser (#) or a regular user (>)
  • %x  refers to the transaction status – usually blank unless in a transaction block (*)

2. color 설정

\set PROMPT1 '%M:%[%033[1;31m%]%>%[%033[0m%] %n@%/%R%#%x '

  • 32 for green
  • 33 for yellow
  • 34 for blue
  • 35 for magenta
  • 36 for cyan
  • 37 for white

 

https://www.digitalocean.com/community/tutorials/how-to-customize-the-postgresql-prompt-with-psqlrc-on-ubuntu-14-04