Thursday, September 17, 2020

[change colour scheme depending on time of day]

Dear all,

I have a rather simple task. I would like Vim to change the colour scheme depending on the time of the day. Please find my solution below. I place it into my ~/.vimrc file. I'm wondering, maybe there is a more elegant way to do it? Maybe there is a built-in Vim function to enquire the hour of the day?

let hr = substitute(system('date +%H'), "\n", "", "")

" colour scheme setting
if (hr >= 6) && (hr < 18)
  colorscheme solarized8_light
else
  colorscheme solarized8_dark
endif

Thank you for your help!

Best wishes,
Maxim

Maxim Abalenkov \\ maxim.abalenkov@gmail.com
+44 7 486 486 505 \\ http://mabalenk.gitlab.io

No comments:

Post a Comment