Saturday, April 19, 2014

Re: Multiple vim configurations for root

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@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment