Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eww2Z-00061L-Ms for pgsql-general@arkaria.postgresql.org; Fri, 16 Mar 2018 20:33:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eww2X-0004Mr-TG for pgsql-general@arkaria.postgresql.org; Fri, 16 Mar 2018 20:33:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eww2X-0004Mb-77 for pgsql-general@lists.postgresql.org; Fri, 16 Mar 2018 20:33:25 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eww2T-0003CQ-Ei for pgsql-general@lists.postgresql.org; Fri, 16 Mar 2018 20:33:24 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 51EB421181; Fri, 16 Mar 2018 16:33:19 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Fri, 16 Mar 2018 16:33:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=n1FSeFIswab6AD41vEhkrI2WOe+D9 zWNfwg+7L/JV6I=; b=G4TuraXaomzWbxwKK7HN7bqOjjo7g7Uux2QmnG2FwkPsf 68h0rzpqz90aJfIG56QyHYHCkYN0hB0+Qulfh30Td21zFE7xlZ3WwtWK2Xb1hyeV HzSs05dxroYF84laOpyPh5gClQsvSjenInTeaXuTZiL+Y0NAzxQ3QdwBu+KMVxr7 lYDV5CtILzJVp7ny5rQrKfc/zoCsot1qZTyfgyq/ywgljJhuK0Oew7NrEhSKHGNL ksm5q7acGSSsEDi+vfII6Yt9msJMs6Rtm1j6MwF+xnvNggd24q9QiwjOE7AYdDT1 AeYfe9gNFpmLe+TBP4MFt3QVCHii8EIpxmiT98nzQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=n1FSeF Iswab6AD41vEhkrI2WOe+D9zWNfwg+7L/JV6I=; b=KFx1/zgDNPTsBJY6EE6xeP pk3BSVUvLgDb9qlySMKAxqQj5O2yz7a079ujKX6ZFDR6VvNpQ/GuggRg2+WeAZVW WpoKP2AkeGXjugwKsk4wZvyLicm1bZIIrVpcr9k21NRKj+YEPxz5dCXt/wVcxx6T YIS7j2vlNPnWBNI5eeOyHPYQPshEDVDNPlrEjuPe58AaAXkOJoVacth90BQgvSmU 3EmYjVVl7VkXHF8VJzCdyfmYMMvgjhXi9I3PPfoTwPmUvqdIROJDc6n/STMdCiOq NDEnAfyH+WR5G7uUcnDl7T9pJt1gAFXzQ3x6c3RWgzqG7ae4GR8u7F3r3JS4HNwg == X-ME-Sender: Received: from [192.168.1.2] (71-35-123-124.tukw.qwest.net [71.35.123.124]) by mail.messagingengine.com (Postfix) with ESMTPA id B14FF7E1F6; Fri, 16 Mar 2018 16:33:18 -0400 (EDT) Subject: Re: Nvim as external editor in psql as Postgres root user - .vimrc (environment?) issue To: Victorias.Linux@gmail.com, "pgsql-general@lists.postgresql.org" References: <20180316104746.1e23e682@gmail.com> <423630eb-637d-8158-3325-ee036910b2c6@aklaver.com> <20180316110517.221f9c7f@gmail.com> <20180316130654.650599b5@gmail.com> From: Adrian Klaver Message-ID: <155e58d8-6fde-727c-4569-d4f23468c592@aklaver.com> Date: Fri, 16 Mar 2018 13:33:17 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180316130654.650599b5@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 03/16/2018 01:06 PM, Victoria wrote: > Ok, here is a clumsy solution. Still not sure why you want to run as the system postgres user. The system user postgres is not the same as the Postgres database user postgres. It is just convention that the system user that Postgres runs as is called postgres. If you want to work in Postgres as the database user postgres you just need to supply -U postgres to the client(psql in this case). You can do that from your home account(victoria) without all the contortions below:) > > I have this entry in my /home/victoria/.psqlrc file, > > \setenv EDITOR "/usr/bin/nvim" > > As you see below, I symlink to that file, from postgres. > > [victoria@victoria ~]$ sudo -u postgres -i > > [postgres@victoria ~]$ pwd > > /var/lib/postgres > > [postgres@victoria ~]$ ls -la > > total 108 > drwxrwxr-x 6 postgres victoria 4096 Mar 16 12:48 . > drwxr-xr-x 33 root root 4096 Mar 16 00:00 .. > -rw------- 1 postgres postgres 385 Mar 16 12:49 .bash_history > -rwxr-xr-x 1 root root 806 Mar 16 12:41 .bashrc > drwx------ 2 postgres postgres 4096 Mar 16 12:23 .cache > drwxrwxr-x 2 postgres victoria 4096 Feb 23 13:26 data > drwx------ 3 postgres postgres 4096 Mar 16 12:12 .local > lrwxrwxrwx 1 postgres victoria 62 Feb 23 15:10 .psql_history-postgres -> /mnt/Vancouver/Programming/RDB/postgres/postgres/.psql_history > lrwxrwxrwx 1 postgres victoria 22 Feb 23 14:59 .psqlrc -> /home/victoria/.psqlrc > drwxr-xr-x 2 postgres postgres 4096 Mar 16 12:38 .vim > -rw------- 1 postgres postgres 895 Mar 16 12:48 .viminfo > -rw-r--r-- 1 postgres postgres 68234 Mar 16 12:47 .vimrc > > ## NOTE: .bashrc and .vimrc are edited COPIES (not symlinks) of /home/victoria/{.bashrc | .vimrc} > > [postgres@victoria ~]$ cat /var/lib/postgres/.bashrc > > export PSQL_EDITOR="/usr/bin/nvim -u /var/lib/postgres/.vimrc" > > ## "/var/lib/postgres/.vimrc" is the same as "/home/victoria/.vimrc" EXCEPT > ## that I commented out line 77, "execute pathogen#infect(), as that was > ## throwing an error when starting nvim (Neovim) as the psql \e external editor. > > ## Important (slight annoyance: need to load that "postgres" .bashrc file: > > [postgres@victoria ~]$ exec bash > > [postgres@victoria ~]$ psql > > psql (10.2) > Type "help" for help. > > [postgres]# \e ## can edit in Neovim, with ~/.vimrc settings, preferences, customizations ... > > [postgres]# \q > > [postgres@victoria ~]$ exit > > exit > > [victoria@victoria ~]$ > > I wasn't able to automatically run the "exec bash" command after starting postgres, hence the need to manually run it in the postgres shell, prior to launching psql. > > ============================================================================== > > -- Adrian Klaver adrian.klaver@aklaver.com