Skip to content

Instantly share code, notes, and snippets.

@yocoldle
Created July 18, 2023 11:42
Show Gist options
  • Save yocoldle/fad77c9e74c8ab9cb1268924253b7f71 to your computer and use it in GitHub Desktop.
Save yocoldle/fad77c9e74c8ab9cb1268924253b7f71 to your computer and use it in GitHub Desktop.
vimscript func: RandomColorscheme
" Random colorscheme function
function! RandomColorscheme()
" Get a list of all colorschemes
let s:colorschemes = split(globpath(&rtp, 'colors/*.vim'), '\n')
" Remove the path and extension from each colorscheme name
let s:colorschemes = map(s:colorschemes, 'fnamemodify(v:val, ":t:r")')
" Remove unwanted colorschemes
let s:colorschemes = filter(s:colorschemes, 'v:val != "blue" && v:val != "darkblue" && v:val != "default" && v:val != "delek" && v:val != "morning" && v:val != "peachpuff" && v:val != "shine" && v:val != "zellner"')
" Select a random colorscheme from the list
let s:random_colorscheme = s:colorschemes[rand() % len(s:colorschemes)]
" Set the color scheme
execute 'colorscheme ' . s:random_colorscheme
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment