If you intend on having multiple hosts/database connections, the ~/.pgpass file is the way to go.
Steps:
vim ~/.pgpass
or similar. Input your information in the following format:
hostname:port:database:username:password
Do not add string quotes around your field values. You can also use * as a wildcard for your port/database fields.chmod 0600 ~/.pgpass
in order for it to not be silently ignored by psql.alias postygresy='psql --host hostname database_name -U username'
The values should match those that you inputted to the ~/.pgpass file.. ~/.bashrc
or similar. Note that if you have an export PGPASSWORD='' variable set, it will take precedence over the file.