psql
without arguments, then the psql
tries to connect to database named like current user. I dislike this behave. Surely I have not database "pavel". There is trivial solution - add to your .bashrc code:function psql { if [[ $# -eq 0 ]]; then env psql postgres else env psql "$@" fi }
Alternatively use the ENV:
ReplyDeleteexport PGDATABASE=postgres
in .bashrc/.zshrc or similar
@anonymous: good to know, thank you
ReplyDeleteSimilarly, you can set things like PGSERVICE in your environment if you're using psql to access remote systems most of the time. There are a fair number of other customizations of this type. http://www.postgresql.org/docs/9.5/static/app-psql.html#AEN9442
ReplyDelete