Postgres external editor does not execute query on savequit

烂漫一生 提交于 2020-01-01 12:06:16

问题


This is driving me slightly insane. I'm trying to edit a query using \e in postgres, but upon savequitting :wq nothing happens. Running \p, which shows what the editor saved, just comes up with a blank line, or whatever I ran most recently in the cli. It seems likethe editor is not persisting whatsoever.

I'm using vim as my default editor, and I'm on psql version 9.5.4. Operating system is OSX and I'm using iterm2. The only similar problem I could find online was here, and no advice there seemed to help.

All ideas are welcomed!

EDIT: Found the problem. It was something to do with my vim -- things worked when I set my editor to Pico, so I nuked my vimrc and slowly readded things. Oddly, when everything was up again it continued to work. So check if it works with another editor!


回答1:


I don't know why exactly but it looks like the $EDITOR environment variable needs to be set for this to work.

Start psql like this:

EDITOR=vim psql ...

Or longer term, add

export EDITOR=vim

to your .bashrc or equivalent.




回答2:


I have confirmed that this occurs when using the Janus vim distribution, and have created an issue over there to track it. Once resolved over there it'll give us a clue and I can give a specific answer here.

In the interim add the following to your ~/.profile as a workaround:

export PSQL_EDITOR="vim -u NONE"

You will lose Janus functionality (and anything else in your .vimrc.before and .after, but it will let you use vim.


See:

  • vim -u switch.
  • PSQL_EDITOR env var.


来源:https://stackoverflow.com/questions/41472024/postgres-external-editor-does-not-execute-query-on-savequit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!