Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

defy69

macrumors newbie
Original poster
Dec 1, 2010
11
0
i was wondering if anyone knew how to modify geektool scripts to displaying a calendar to show the first 9 days as double digits (with a zero added). right now im using the simple version:

cal | sed -n '2,8p'

screenshot20101202at815.jpg


the font im using (dymofontinverse) is a fixed-width for all the letters and numbers, but the spaces are just blanks instead of a matching fill.




is it easy enough to change the geektool command, or should i try to modify the font file?




thanks
 
Last edited:
Could you explain what you're wanting a little more? This part, "the first 9 days a double digits" was especially confusing. Maybe some examples would help.
 
***the first 9 days as double digits

sorry about that, im terrible at catching my own mistakes
 
This seems to work:
Code:
cal | sed -n '2,8p' | sed ':a;N;$!ba;s/ \([0-9]\)\([ \n]\)/0\1\2/g'
which currently gives:
Code:
Su Mo Tu We Th Fr Sa
         01 02 03 04
05 06 07 08 09 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
This page has some discussion on the weird part at the beginning of the sed command.
 
I was using Ubuntu so that might have made a difference. Try this one.
Code:
[s]cal | sed -n '2,8p' | sed 's/ \([0-9]\)\( \|$\)/0\1\2/g'[/s]
Edit: OK, apparently there are some Unix/Linux differences with the regex stuff. Back at my Mac so can actually test. Here's something that works from Mac 10.6.
Code:
cal | sed -n '2,8p' | sed -e 's/ \([0-9] \)/0\1/g' -e 's/ \([0-9]$\)/0\1/g'
and another alternative that's a little shorter,
Code:
cal | sed -n '2,8p' | sed -E 's/ ([0-9])( |$)/0\1\2/g'
 
Last edited:
thanks a lot

if doesn't fix my problem entirely. im glad to see there is a way to get all the dates to show up as double digits. But the font im using is really causing the alignment problems
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.