Last active
September 6, 2019 07:02
-
-
Save heygarrett/5564265 to your computer and use it in GitHub Desktop.
Solarized: Night & Day
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
" Set colorscheme to solarized | |
colorscheme solarized | |
" Change the Solarized background to dark or light depending upon the time of | |
" day (5 refers to 5AM and 17 to 5PM). Change the background only if it is not | |
" already set to the value we want. | |
function! SetSolarizedBackground() | |
if strftime("%H") >= 5 && strftime("%H") < 17 | |
if &background != 'light' | |
set background=light | |
endif | |
else | |
if &background != 'dark' | |
set background=dark | |
endif | |
endif | |
endfunction | |
" Set background on launch | |
call SetSolarizedBackground() | |
" Every time you save a file, call the function to check the time and change | |
" the background (if necessary). | |
if has("autocmd") | |
autocmd bufwritepost * call SetSolarizedBackground() | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instead of repeating the logic that is already in the function, replace your second section (starting "Launch vim with light background...") to just
call SetSolarizedBackground()
.Always be DRY (Don't Repeat Yourself).