How to reference/source a custom .vimrc file

后端 未结 9 1308
生来不讨喜
生来不讨喜 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 05:10

    Method 2 - as an addition to .vimrc

    tried different things
    tty does not work, and system("who am i") neither (they come up empty when used from within vim-function), so this way is much longer. Any shortcuts are welcome

    "Local .vimrc for the user
    " 1. get the user, which used su
    " 2. we can load his .vimrc.
    " from $HOME (from where we have sudo'ed in)
    let b:term = substitute( system ("ps T | grep ' ps T$' | sed -e 's/^  *//' | cut -d ' ' -f 2 "), "\n", "", "" )
    let b:user = substitute( system ("who | grep ".b:term." | cut -d ' ' -f 1 "), "\n", "", "" )
    let b:file = $HOME."/.vimrc.".b:user
    if filereadable(b:file)
      execute 'source '.b:file
    endif
    

提交回复
热议问题