random.vim 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "----------------------------------------------------------"
  2. " Vim meta color file "
  3. " Maintainer : W. H. Jou "
  4. " Email : whjou@singnet.com.sg "
  5. " Most Recent Update : 2003-09-15 "
  6. " Version : 1.3 "
  7. "----------------------------------------------------------"
  8. " Define function once only
  9. if !exists("*s:LoadRandomColorScheme")
  10. function s:LoadRandomColorScheme()
  11. let s:self = globpath(&runtimepath, 'colors/random.vim')
  12. let s:color_file_list = globpath(&runtimepath, 'colors/*.vim' )
  13. let s:self = substitute(s:self , '\' , '/', 'g')
  14. let s:color_file_list = substitute(s:color_file_list, '\' , '/', 'g')
  15. let s:color_file_list = substitute(s:color_file_list, s:self . "\n", '' , 'g')
  16. let s:color_file_list = substitute(s:color_file_list, "\n" , ',', 'g')
  17. if strlen(s:color_file_list)
  18. if s:color_file_list =~ ','
  19. let s:rnd = matchstr(localtime(), '..$') + 0
  20. let s:loop = 0
  21. while s:loop < s:rnd
  22. let s:color_file_list = substitute(s:color_file_list, '^\([^,]\+\),\(.*\)$', '\2,\1', '')
  23. let s:loop = s:loop + 1
  24. endwhile
  25. let s:color_file = matchstr(s:color_file_list, '^[^,]\+')
  26. execute "source" s:color_file
  27. unlet! s:color_file
  28. unlet! s:loop
  29. unlet! s:rnd
  30. endif
  31. endif
  32. unlet! s:color_file_list
  33. unlet! s:self_file
  34. endfunction
  35. endif
  36. "----------------------------------------------------------"
  37. call s:LoadRandomColorScheme()