How do I create a psql alias for "\q"? I'm using Postgres 9.5 on Ubuntu 14.04.  Even after using Postgres for a year, I can't get used to typing \q to exit my command line session.  My fingers just want to type "exit" or "quit".  How can I create an alias that does the same thing as \q in my Postgres command line session?
Don't use \q. Use CTRL + D. This sends End-of-file (EOF). It works on all interactive terminals (at least the ones built with readline, afaik)


  readline returns the text of the line read. A blank line returns the empty string. If EOF is encountered while reading a line, and the line is empty, NULL is returned. If an EOF is read with a non-empty line, it is treated as a newline.


Most of the interactive terminals and REPL utilities you use, use some variation of readline or libedit. They all run in a loop that process lines. When you type CTRL+D your terminal inserts the EOF signal, the loops get a null pointer, and the program reads that by convention as a desire to quit.

You can't make exit nor quit an alias in psql, because psql doesn't have aliases like bash; but, both of your other utilities that use exit and quit should work with CTRL+D. It's a good muscle memory to develop.

Two minor footnotes...


If you're on DOS or the newer graphical version, use CTRL+Z to send EOF. That's also the MS Word hotkey for Undo.
I'm not actually describing what happens in UNIX either. I'm keeping it simple. CTRL+D really sends End-of-Transmission (EOT) which causes the terminal to send EOF.