通过环境变量 PGDATABASE、PGHOST、 PGPORT以及PGUSER 设置Connection options缺省值。
export PGPORT=5433设置缺省port
export PGUSER=postgres设置缺省username
psql --help
Connection options: --host=HOSTNAME database server host or socket directory (default: "local socket") --port=PORT database server port (default: "5433") --username=USERNAME database user name (default: "postgres") --no-password never prompt for password --password force password prompt (should happen automatically)
-bash-4.2$ psql psql (9.6.19) Type "help" for help.
postgres=# show port; port ------ 5433 (1 row)
postgres=# select current_user; current_user -------------- postgres (1 row)
postgres=#