How to reference/source a custom .vimrc file

后端 未结 9 1303
生来不讨喜
生来不讨喜 2020-12-08 04:24

Is there a way to reference (or \"source\") another user\'s .vimrc file?

When I kuu (a variant of su that uses kerberos security tokens) to

9条回答
  •  误落风尘
    2020-12-08 04:58

    I'm assuming that your initial owner owns your tty. If so, you can get your initial USER with:

    stat -c'%U' `tty`
    

    By placing your customized root .vimrc in /root/.vimrc.$USRNAME you can keep a reasonably secure customized vimrc file. You can do other things too, but I leave that to your imagination.

    Method 1 - put this in your /root/.bashrc & smoke it:

    # Source a custome vimrc if it exists
    mytty=`tty`
    initial_user=`stat -c'%U' $mytty`
    custom_vimrc="/root/.vimrc.$initial_user"
    if [ -f $custom_vimrc ]; then
        export VIMINIT="source $custom_vimrc"
    fi
    

    Method 2 - put something similar in your /root/.vimrc (a better solution since you might use ksh).

    If anyone can figure out Method 2, I'd welcome the post. I lack motivation.

提交回复
热议问题