On 20th of July, Robert Haas committed (and later committed change to it) patch which adds another \* command to psql:
Log Message: ----------- Add \conninfo command to psql, to show current connection info. David Christensen. Reviewed by Steve Singer. Some further changes by me.