Skip to content

Instantly share code, notes, and snippets.

@vagmi
Created December 18, 2014 00:56
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vagmi/e29f42d2f2f11bdfc81f to your computer and use it in GitHub Desktop.
Save vagmi/e29f42d2f2f11bdfc81f to your computer and use it in GitHub Desktop.
function! RandomNumber(limit)
let components = split(reltimestr(reltime()), '\.')
let microseconds = components[-1] + 0
return microseconds % a:limit
endfunction
function! RandomScheme()
let choices = []
for fname in split(globpath(&runtimepath, 'colors/*.vim'), '\n')
let name = fnamemodify(fname, ':t:r')
let choices = choices + [name]
endfor
let index = RandomNumber(len(choices))
execute 'colorscheme' fnameescape(choices[index])
endfunction
let g:total=1
function! SwitchScheme()
call feedkeys("f\e")
if(g:total % 15 == 0)
" update time is usually set to 4 seconds
" So the scheme would be changed on 1 minute of inactivity
call RandomScheme()
endif
let g:total = g:total + 1
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment