Loading ...
Sorry, an error occurred while loading the content.

Multiple vim configurations for root

Expand Messages
  • Magee, Fred
    The other Linux system admin and I have dramatically different ideas about how vim should be configured. Is it possible for me to create a test for user id and
    Message 1 of 6 , Apr 18, 2014
    • 0 Attachment

      The other Linux system admin and I have dramatically different ideas about how vim should be configured. Is it possible for me to create a test for user id and use my vim configuration  including plugins etc.  that I can use when using vim as root? For example is there an environment variable vim uses for config files I can set when I su to root?

       

      I’m running several versions of vim over Red Hat RHEL 4, 5, 6 and RH9. The most common is 7.0.237.

       

      Fred Magee, DTM

      Systems Programmer

      (505)768-2978

      (505)768-4615 (Fax)

      (505)205-5753 (Cell)

      fmagee@...

       

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/d/optout.
    • Tim Chase
      ... I don t believe there s an environment variable, per-se, but you can specify it on the command-line: vim -u fred_vimrc which you could easily alias in your
      Message 2 of 6 , Apr 18, 2014
      • 0 Attachment
        On 2014-04-18 11:52, Magee, Fred wrote:
        > The other Linux system admin and I have dramatically different ideas
        > about how vim should be configured. Is it possible for me to create
        > a test for user id and use my vim configuration including plugins
        > etc. that I can use when using vim as root? For example is there an
        > environment variable vim uses for config files I can set when I su
        > to root?

        I don't believe there's an environment variable, per-se, but you can
        specify it on the command-line:

        vim -u fred_vimrc

        which you could easily alias in your shell:

        alias vif='vim -u ~/.fred_vimrc'

        -tim





        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.
      • Gary Johnson
        ... I realize this is not what you asked for, but you may be interested in the SudoEdit plugin (http://www.vim.org/scripts/script.php?script_id=2709). It will
        Message 3 of 6 , Apr 18, 2014
        • 0 Attachment
          On 2014-04-18, Magee, Fred wrote:
          > The other Linux system admin and I have dramatically different ideas about how
          > vim should be configured. Is it possible for me to create a test for user id
          > and use my vim configuration including plugins etc. that I can use when using
          > vim as root? For example is there an environment variable vim uses for config
          > files I can set when I su to root?

          I realize this is not what you asked for, but you may be interested in
          the SudoEdit plugin (http://www.vim.org/scripts/script.php?script_id=2709).
          It will allow you to read and write files using your sudo or su
          permissions while running a vim instance that you started as a normal
          user.

          Regards,
          Gary

          --
          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/d/optout.
        • Gary Johnson
          ... You could use the VIMINIT environment variable and set it something like this after you login as root: VIMINIT=/home/fred/.root_vimrc Vim sources your
          Message 4 of 6 , Apr 18, 2014
          • 0 Attachment
            On 2014-04-18, Magee, Fred wrote:
            > The other Linux system admin and I have dramatically different ideas about how
            > vim should be configured. Is it possible for me to create a test for user id
            > and use my vim configuration including plugins etc. that I can use when using
            > vim as root? For example is there an environment variable vim uses for config
            > files I can set when I su to root?

            You could use the VIMINIT environment variable and set it something
            like this after you login as root:

            VIMINIT=/home/fred/.root_vimrc

            Vim sources your plugins from the directories in 'runtimepath' which
            it builds on startup using the value of $HOME. To make Vim source
            your personal plugins, put the following in /home/fred/.root_vimrc:

            let &rtp = substitute(&rtp, "/root", "/home/fred", "g")
            source /home/fred/.vimrc

            To verify that you're getting the right set of plugins as you
            experiment with the above, use the ":scriptnames" command.

            See

            :help VIMINIT
            :help 'rtp'
            :help :scriptnames

            Regards,
            Gary

            --
            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/d/optout.
          • Erik Christiansen
            ... Once you are root it is too late, AFAICT. We anticipate that the effective user ID is: # id -u 0 But the real user ID is the same: # id -ur 0 I.e. we
            Message 5 of 6 , Apr 19, 2014
            • 0 Attachment
              On 18.04.14 11:52, Magee, Fred wrote:
              > Is it possible for me to create a test for user id and use my vim
              > configuration including plugins etc. that I can use when using vim as
              > root?

              Once you are root it is too late, AFAICT. We anticipate that the
              effective user ID is:

              # id -u
              0

              But the real user ID is the same:

              # id -ur
              0

              I.e. we _really_ are root. It's the same for sudo, so it appears that
              the test is only useful in the case of setuid.

              Without a means of differentiation, the simplest fallback seems be to
              "su -p" (i.e. --preserve-environment) That preserves all your little
              aliases and fiddles, e.g.:

              $ which ll
              ll is aliased to `ls -alF'

              $ su -p
              Password:
              root@ratatosk:~# which ll
              ll is aliased to `ls -alF

              So aliasing vim to use an explicitly nominated .vimrc would also be
              respected. (Preservation confirmed only on ubuntu, as I gave up on RH
              more than a decade ago, and stopping to arc up the debian lappy won't
              add much. :)

              Erik

              P.S. OK, yes, because the "type" command is the worst named in the unix
              pantheon, I've used this for more than a quarter of a century:

              $ which which
              which is aliased to `type -a'

              So please substitute "type" for "which", above, if wishing to replicate
              the test without the sanitising alias.

              --
              Less is more or less more.
              - Y_Plentyn on #LinuxGER

              --
              --
              You received this message from the "vim_use" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_use" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/d/optout.
            • Magee, Fred
              Thanks to all who responded. I was very close and you showed me the missing piece. I m going to check out the script Gary Johnson pointed me to. It looks very
              Message 6 of 6 , Apr 21, 2014
              • 0 Attachment

                Thanks to all who responded. I was very close and you showed me the missing piece. I’m going to check out the script Gary Johnson pointed me to. It looks very interesting.

                 

                Fred Magee, DTM

                Systems Programmer

                (505)768-2978

                (505)768-4615 (Fax)

                (505)205-5753 (Cell)

                fmagee@...

                 

                --
                --
                You received this message from the "vim_use" maillist.
                Do not top-post! Type your reply below the text you are replying to.
                For more information, visit http://www.vim.org/maillist.php

                ---
                You received this message because you are subscribed to the Google Groups "vim_use" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                For more options, visit https://groups.google.com/d/optout.
              Your message has been successfully submitted and would be delivered to recipients shortly.