[change colour scheme depending on time of day]

24 views
Skip to first unread message

Maxim Abalenkov

unread,
Sep 17, 2020, 3:54:46 PM9/17/20
to vim...@googlegroups.com
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.a...@gmail.com
+44 7 486 486 505 \\ http://mabalenk.gitlab.io

tooth pik

unread,
Sep 17, 2020, 8:41:11 PM9/17/20
to vim...@googlegroups.com
i think strftime() is what you're looking for

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/7A9F43C0-A964-4D97-B681-1363021170CA%40gmail.com.

Al

unread,
Sep 18, 2020, 2:03:48 AM9/18/20
to vim...@googlegroups.com
Hi Maxim,

>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", "", "")

I believe strftime("%H") will do what you want. According to the help, this isn't particularly portable, so ymmv.

Al

陈世用

unread,
Sep 18, 2020, 1:03:23 PM9/18/20
to vim...@googlegroups.com
I have a plugin change colorscheme depending on working directory:


Hope it could give you some inspiration 

Al <asymp...@posteo.net>于2020年9月18日 周五下午2:03写道:
--

--

You received this message from the "vim_use" maillist.

Do not top-post! Type your reply below the text you are replying to.

For more information, visit http://www.vim.org/maillist.php



---

You received this message because you are subscribed to the Google Groups "vim_use" group.

To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages