4

I am coming from the postgres world, and am not very new to UNIX. My question is, if there is a way to invoke a editor from command line, and when I close the editor the output flows to the shell. Something similar to \e command available in postgres, where I type in a query, edit it easily in a editor instead of in the repl, and then I quit the editor to see the output of what I typed in, along with the query.

4

3 回答 3

6

在 bash 中,您可以ctrl+ xctrl+ e(两笔组合)将 shell 的 readline 发送到您的 $EDITOR。在编辑器退出时,命令被执行。

Zsh 和其他 shell 具有类似的功能,可能需要配置。

于 2013-06-04T11:50:10.330 回答
0

Kate 有一个控制台插件,可让您将文本直接刷新到控制台

在此处阅读更多信息http://www.kde.org/applications/utilities/kate/

编辑:这里更多https://www.linux.com/learn/tutorials/548031-expert-tips-and-tricks-with-kate-and-konsole

于 2013-06-04T10:38:13.327 回答
0

编写一个或多或少执行您所谈论的内容的 shell 脚本很容易。我认为最简单的版本应该是这样的。

$ cat test.sh
vi test.sql
psql -U postgres -h localhost -p 5432 sandbox < test.sql | less
于 2013-06-04T10:43:35.467 回答