There's more…

You can place some psql commands in a profile that will get executed when you run psql. Adding ON_ERROR_STOP to your profile will ensure that this setting is applied to all psql sessions:

$ $EDITOR ~/.psqlrc
\set ON_ERROR_STOP

You can forcibly override this, and request psql to execute without a profile using -X. This is probably the safest thing to do for batch execution of scripts, so they always work in the same way, irrespective of the local settings.

ON_ERROR_STOP is one of some special variables that affect the way psql behaves. The full list is available at the following URL:

https://www.postgresql.org/docs/10/static/app-psql.html#APP-PSQL-VARIABLES