25

Vim-Plug: Run PlugUpdate every week automatically · GitHub

 3 years ago
source link: https://gist.github.com/kkoomen/68319b08ab843ce67cf7b282b0b2fd24
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Run PlugUpdate every week automatically · GitHub

Vim-Plug: Run PlugUpdate every week automatically

This snippet will check every time you run Vim whether it updated all your Plug packages for you. It will do this once a week automatically for you.

Add the following to your .vimrc:

function! OnVimEnter() abort
  " Run PlugUpdate every week automatically when entering Vim.
  if exists('g:plug_home')
    let l:filename = printf('%s/.vim_plug_update', g:plug_home)
    if filereadable(l:filename) == 0
      call writefile([], l:filename)
    endif

    let l:this_week = strftime('%Y_%V')
    let l:contents = readfile(l:filename)
    if index(l:contents, l:this_week) < 0
      call execute('PlugUpdate')
      call writefile([l:this_week], l:filename, 'a')
    endif
  endif
endfunction

autocmd VimEnter * call OnVimEnter()

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK