psql -c '\password' postgres
Enter the new password here.
Add that password to ~/.pgpass:
~/.pgpass
cat > ~/.pgpass && chmod 600 ~/.pgpass
paste the line replacing <user> and <password> values:
<user>
<password>
127.0.0.1:*:*:<user>:<password>
(^D for save)