Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: Set Color/Theme based off time of day

Tags:

vim

I have one of those super glossy monitors, so during the day I can see my own reflection better than my code on Dark themes. So I thought it'd be great if I could have a simple if switch in my vimrc to set either a dark theme or a light theme based on the time of day.

Alas, I don't know enough about vimrc syntax and googling came up short.

Anyone wanna take a crack at this?

like image 269
Jonathan Dumaine Avatar asked Sep 28 '11 19:09

Jonathan Dumaine


2 Answers

Something like the following should do the trick:

if strftime("%H") < 12   set background=light else   set background=dark endif 

Obviously you should choose the hour based on your needs

like image 173
lucapette Avatar answered Oct 03 '22 22:10

lucapette


This is not strictly a Vim answer but you could try to install f.lux which adjusts your monitor colours to the time of the day.

Here is a demo. It has a warm yellowish glow during the day, and blueish one during the night.

Disclaimer : I have not tried it myself (but I am tempted).

like image 42
Xavier T. Avatar answered Oct 03 '22 23:10

Xavier T.