From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Victorias.Linux@gmail.com
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Nvim as external editor in psql as Postgres root user - .vimrc (environment?) issue
Date: Fri, 16 Mar 2018 13:33:17 -0700
Message-ID: <155e58d8-6fde-727c-4569-d4f23468c592@aklaver.com> (raw)
In-Reply-To: <20180316130654.650599b5@gmail.com>
References: <20180316104746.1e23e682@gmail.com>
<423630eb-637d-8158-3325-ee036910b2c6@aklaver.com>
<20180316110517.221f9c7f@gmail.com>
<20180316130654.650599b5@gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, Victorias.Linux@gmail.com
Subject: Re: Nvim as external editor in psql as Postgres root user - .vimrc (environment?) issue
In-Reply-To: <155e58d8-6fde-727c-4569-d4f23468c592@aklaver.com>
References: <20180316104746.1e23e682@gmail.com> <423630eb-637d-8158-3325-ee036910b2c6@aklaver.com> <20180316110517.221f9c7f@gmail.com> <20180316130654.650599b5@gmail.com> <155e58d8-6fde-727c-4569-d4f23468c592@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox