geektool calendar - 2 digit date

Discussion in 'Mac Apps and Mac App Store' started by defy69, Dec 1, 2010.

  1. defy69, Dec 1, 2010
    Last edited: Dec 2, 2010

    defy69 macrumors newbie

    Joined:
    Dec 1, 2010
    #1
    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'

    [​IMG]

    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
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    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.
     
  3. defy69 thread starter macrumors newbie

    Joined:
    Dec 1, 2010
    #3
    ***the first 9 days as double digits

    sorry about that, im terrible at catching my own mistakes
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    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.
     
  5. defy69 thread starter macrumors newbie

    Joined:
    Dec 1, 2010
    #5
    didnt work for me, in geektool and in terminal
     
  6. angelwatt, Dec 2, 2010
    Last edited: Dec 2, 2010

    angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #6
    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'
     
  7. defy69 thread starter macrumors newbie

    Joined:
    Dec 1, 2010
    #7
    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
     

Share This Page