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)
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()
@orrpeles You can run the snippet in a headless way by running
vim +PlugUpdate +qa > /dev/null 2&>1
. This won't show vim but will run vim with the given commands.You should be able to bind this to cron in some way. Didn't get it to work myself for some reason, maybe this had to do that cron did run as root and root has no plugins on my system.