Skip to content

Instantly share code, notes, and snippets.

@jgoodall
Created November 12, 2012 18:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jgoodall/4061048 to your computer and use it in GitHub Desktop.
Save jgoodall/4061048 to your computer and use it in GitHub Desktop.
shell script to print a calendar to the screen, highlighting today (geektool)
#!/bin/sh
# useful for [geektool](http://projects.tynsoe.org/en/geektool/)
#
# colorcal - change current day and date via ANSI color escape sequences
# see http://www.termsys.demon.co.uk/vtansi.htm for color codes.
color="\033[1;33m"
underline="\033[4m"
reset="\033[0m"
# get day & date
current_day=`/bin/date "+%a" | cut -b 1,2`
current_date=`date | awk '{print $3}'`
#color em.
color_day=`echo "${underline}${current_day}${reset}"`
color_date=`echo "${color}${underline}${current_date}${reset}"`
# format cal output so the sed replacements work at begining and end of cal output.
function calendar {
/usr/bin/cal | sed 1d | sed 's/ /_/g' | sed -e 's/^/ /' -e 's/$/_/' | sed 's/_/ /g'
}
# run calendar & substitute colored day & date.
calendar | /usr/bin/sed -e "s/ ${current_day} / ${color_day} /" -e "s/ ${current_date} / ${color_date} /"
# END of colorcal
@corporate-gadfly
Copy link

Came up with the following recipe for a colorized calendar in geektool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment