Welcome

Troves being gleaned while surfing on the Internet mostly about computer/IT/system skills and tricks, Welcome here ...
Powered By Blogger

Disclaimer

This blog is written by the owner with real practices and tests and intended to hold all original posts except there is a clear declaration for referencing from others. Thanks for tagging with the source link or other tips for reference from here if you would like to quote partial or full text from posts in this blog.

Monday, January 3, 2011

A Funny Time Varying VIM color scheme switching

Vi/vim is really the most popular editor under Linux esp. for those advanced users or Linux fans, even though there are dozen of other featured ones including visual editors and the most worthy of mentioning, Emacs for programming gurus.

Here I just got a whimsy yet actually a fortuitous idea, to make this editor of daily use to be adaptive with current local time periods such as morning, noon, evening and other phases of a day.

The snippet  meant to be placed in or tailed at the vim configuration file, as is mostly the /etc/vimrc or $HOME/vimrc, will make the vim editor apply different color scheme that is meaningfully in accordance with the time of period when vim is launched. Additionally, color schemes for other time of period than morning and evening will be changed with the weekday.


" # intelligent colorscheme switching
let weekday=system('date +%u')
let hour=system('date +%H')

" if the shell command gets any exception during execution, nothing will be 
" done on color scheme setting
if !v:shell_error


   " in other time slots than mornings and evenings, scheme to be applied depends 
   " on which the weekday it is today, beginning from 1 as Monday, through 6 as 
   " Saturday and Sunday numbered as 0
    if     1== weekday
        let coloration="elflord"
    elseif 2 == weekday
        let coloration="koehler"
    elseif 3 == weekday
        let coloration="slate"
    elseif 4 == weekday
        let coloration="zellner"
    elseif 5 == weekday
        let coloration="torte"
    elseif 6 == weekday
        let coloration="ron"
    else "Sundays
        let coloration="blue"
    endif 
 
    " exert the color scheme application
    execute "colorscheme ".coloration 
 
    " in mornings, alwasy using the "morning" scheme
    if hour >= 7 && hour <= 10
        let coloration="morning"
    " in evenings, alwasy using the "evening" scheme
    elseif hour >= 18 && hour <= 23
        let coloration="evening"
    endif
 
endif


Just give it a try, you may be intrigued with use of it afterwards like me!

-----------------------------------
other interesting links
-------------------------------------

Full range of vim color scheme implemented in a Google code project
http://vimcolorschemetest.googlecode.com/svn/html/index-c.html

A find-tweaked color scheme for Mac:
http://blog.toddwerth.com/entries/show/8

1 comment:

Anonymous said...

Magnificent beat ! I wish to apprentice while you amend your web site,
how could i subscribe for a blog web site? The account aided me a acceptable deal.

I had been tiny bit acquainted of this your broadcast offered
bright clear concept

Also visit my website Healthy Diet
Also see my website: healthy diet plans for women