Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been looking for a command line calendar program for Linux for quite some time now. I realized I should just use vim. I want to be able to easily view a week of todo lists. Currently using this command:

data=$(unset split; echo -n "-c \""; for i in {6..0}; do if [ $i -ne 6 ] ; then split="vsplit"; else split="e"; fi; echo -n "$split $(date +"%F" -d"last sunday+$i day").txt|"; done; echo "\"") && precmd='-c "split todo.txt" -c "Calendar" -c "wincmd w"' && cmd="vim $precmd $data" && eval $cmd

Run this in a full screen terminal, otherwise you're gonna have a bad time. Requires this calendar plugin: https://github.com/mattn/calendar-vim If you don't have the vim calendar plugin, this will work too but it won't have the calendar:

data=$(unset split; echo -n "-c \""; for i in {6..0}; do if [ $i -ne 6 ] ; then split="vsplit"; else split="e"; fi; echo -n "$split $(date +"%F" -d"last sunday+$i day").txt|"; done; echo "\"") && precmd='-c "split todo.txt"' && cmd="vim $precmd $data" && eval $cmd

This does exactly what I want, except that the lower pane does not load my rolling todo.txt. If I could just get that lower pane to load my todo.txt, I would be all set! I can't figure out why vim won't accept my:

-c "split todo.txt"

Feel free to correct my horrendous bash as well.

Also, I do realize that the vim calendar plugin has a "diary" feature, but AFAIK it doesn't split the window as I require.

Thanks!

Edit: Here is an updated version which fixes an issue when run on Sundays, and also allows you to specify the week offset, ie, "vimcal 0" "vimcal 1" "vimcal -1" etc. (Of course you will need to create a script and/or alias)

data=$(unset split; unset day; echo -n "-c \""; for i in {6..0}; do if [ $i -ne 6 ] ; then split="vsplit"; else split="split"; fi; if [ `date +"%A"` = "Sunday" ] ; then day="sunday"; else day="last sunday"; fi; echo -n "$split $(date +"%F" -d"$day+$i day+$1 week").txt|"; done; echo "\"") && precmd='-c "edit todo.txt" -c "Calendar" -c "wincmd w"' && cd ~/Documents/todo && cmd="vim $precmd $data" && eval $cmd
share|improve this question

1 Answer 1

up vote 2 down vote accepted

Vim does execute the :split todo.txt; you'll see the (hidden) file in the output of :ls!. The problem becomes apparent when you print the executed command line (by replacing eval with echo):

vim -c "split todo.txt" -c "e 2013-10-05.txt|vsplit 2013-10-04.txt|vsplit 2013-10-03.txt|vsplit 2013-10-02.txt|vsplit 2013-10-01.txt|vsplit 2013-09-30.txt|vsplit 2013-09-29.txt|"

From the default empty buffer, you :split off the todo.txt file, and then, in that same window :edit the first dated file. You need to swap the two opening commands, like this:

data=$(unset split; echo -n "-c \""; for i in {6..0}; do if [ $i -ne 6 ] ; then split="vsplit"; else split="split"; fi; echo -n "$split $(date +"%F" -d"last sunday+$i day").txt|"; done; echo "\"") && precmd='-c "edit todo.txt"' && cmd="vim $precmd $data" && eval $cmd
share|improve this answer
    
Awesome! :D It works perfectly, thank you for your help! –  cat pants Oct 2 '13 at 17:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.