A couple of months ago, I was wondering would it be the third year or fourth year since this blog was born? I could remember the month and day, but hardly the year. Knowing which anniversary almost is impossible and that’s the reason I wrote nthanniv script in Python, a script is so simple with less than 80 lines and most of them are comments and blank lines.
In the screenshot above, the first part is the configuration file. As you can see, it’s a simple plain text file. Date and description for the date, and that’s all.
The second part is the output being piped into sort command, so it shows what anniversaries come next. For example, the first entry, first column tells the second anniversary has passed and second column says that the third anniversary will be in 1 day.
Simple to read and to code.
I didn’t complicate the script. There is no options and there is no need. If you need something, pipe into your script like how I use sort. You can even write a script to generate notification when the second column is a number lower than a threshold.
For example, highlighting upcoming anniversaries within 30 days:
nthanniv | sort -k 2 | awk \
'{if($2<=30) {print "\033[1;31m"$0"\033[0m"} else {print $0}}'
In just one day, it marks that I’ve not eaten any meat for three years. Little more than two years ago, I revealed that I became lacto-vegetarian because of a television show. A year later, a Flickr video turned me into vegan. Last year, it’s my fifth year anniversary of being a full-time Linux user.
Time sure flies by fast and this is I need to have this simple script to help me track the dates.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.