Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

What do I put in ~/.psqlrc file to set the default editor?

The editor I want to use (Textmate) is at /Users/username/bin/mate.

I found the place in the docs where they talk about it, and tried several syntax variations, but can't seem to get it to work.

For example, this didn't work...

\set PSQL_EDITOR "/Users/username/bin/mate"

In psql when I enter \e I get...

sh: /usr/local/bin/mate: No such file or directory
sh: line 0: exec: /usr/local/bin/mate: cannot execute: No such file or directory
share|improve this question
For me \set PSQL_EDITOR /usr/bin/vim works. Are you sure that the binary is called mate? –  dezso Jun 29 '12 at 6:56
I suspect /Users/username/bin/mate is a symbolic link to /usr/local/bin/mate, which doesn't exist. –  tblPhil Jun 29 '12 at 7:18
Yes, it's a symlink. I tried setting it to the direct path to the executable. Same result. –  Ethan Jun 29 '12 at 17:20
Are you unable to change the default editor at all or is it just Textmate you can't change it to? –  Jack Douglas Jul 1 '12 at 18:01

2 Answers 2

Contrary to my comment above (which was the result of insufficient testing), you should put a line into .bashrc (or any similar place):

export PSQL_EDITOR="/Users/username/bin/mate"

In psql coming with PostgreSQL 9.2, there is a \setenv command, it is supposed to work from .psqlrc as well.

(Credits to Pedro Romano.)

share|improve this answer
Minor typo above (missed the equal sign): export PSQL_EDITOR="/usr/bin/vi" –  Tony Mar 17 at 1:02
@Tony fixed, thanks. –  dezso Mar 17 at 8:33

Try setting it to whatever you type to run the application from the shell. If that doesn't work, try running the editor from the shell to troubleshoot.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.