Run postgres.app from the command line

I recently started using tmux on my macbook which lets me setup workspaces for different projects. One of these projects requires postgres to be running. I use the fantastic postgres.app for mac which takes away all the faff of installing postgres yourself. They have a set of instructions for installing the command line tools which lets you run the postgres command. Unfortunately simply running postgres is not enough. Here’s the steps I took:

You should now have a postgres server running from the command-line with output similar to:

2021-01-05 16:09:42.445 CET [11710] LOG:  starting PostgreSQL 12.5 on x86_64-apple-darwin16.7.0, compiled by Apple LLVM version 8.1.0 (clang-802.0.42), 64-bit
2021-01-05 16:09:42.451 CET [11710] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2021-01-05 16:09:42.451 CET [11710] LOG:  listening on IPv6 address "::1", port 5432
2021-01-05 16:09:42.452 CET [11710] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2021-01-05 16:09:42.545 CET [11710] LOG:  database system is ready to accept connections