Skip to content

Instantly share code, notes, and snippets.

@veirus
Last active May 29, 2017 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veirus/678f2f919333505acc402bba16328b2b to your computer and use it in GitHub Desktop.
Save veirus/678f2f919333505acc402bba16328b2b to your computer and use it in GitHub Desktop.
Set random colorscheme for yer Vim
function! SetRandomColors()
if !exists('g:mycolors')
let matches = {}
for fname in split(globpath(&runtimepath, 'colors/*.vim'), '\n')
let name = fnamemodify(fname, ':t:r')
let matches[name] = 1
endfor
let g:mycolors = sort(keys(matches), 1)
endif
exe 'colorscheme ' . g:mycolors[localtime() % len(g:mycolors)]
call SetCursorModes()
redraw
if has('title')
set titlelen=99
set titlestring=%t%(\ %M%)\ -%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)\ -\ %{g:colors_name}
endif
endfunction
command! Rcl call SetRandomColors()
map <F9> :call SetRandomColors()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment