Created
July 18, 2023 11:42
-
-
Save yocoldle/fad77c9e74c8ab9cb1268924253b7f71 to your computer and use it in GitHub Desktop.
vimscript func: RandomColorscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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