Tab completion makes it easy to change psql settings interactively, removing the need to memorize options or spend time searching through documentation.

Realizing these builtin cheatsheets are always at my fingertips has improved my productivity in psql tremendously.

:information_source: Enter \? variables in psql for help with psql variables.
:bulb: Or enter \? v<TAB> and let tab completion finish the word.

Most of the options that can be specified when launching psql can also be changed while it’s running, using either the \pset or \set meta-commands.

To list display options, enter \pset <TAB><TAB>:

Screenshot: tab completions for \pset

For display settings (but not other options), enter an option without a value to see its current setting.

Screenshot: linestyle value shown by entering "\pset linestyle"

Some settings also have completions for valid values:

Screenshot: tab completions for \pset linestyle

Other psql options are stored in “specially treated” variables which can be changed with \set.

By convention, psql variables in upper case are used by psql, not of all which can be changed. Depending on your psql configuration, completions might include lower case variables used for other purposes as well.

Enter \set <TAB><TAB> to see completions for psql variables:

Screenshot: tab completions for \set

Some variables also have completions for valid settings:

Screenshot: tab completions for \set VERBOSITY

Unlike \pset, if you don’t provide a value for an option, it will be reset to the default. For example, to restore AUTOCOMMIT to its default value of on:

\set AUTOCOMMIT

:warning: Setting a PROMPT variable to nothing will not restore the default prompt.

Tab completion on Windows: Tab completion is not available for psql on Windows but reportedly works for psql running on WSL (Windows Subsystem for Linux).