Skip to content

Instantly share code, notes, and snippets.

@tzarskyz
Forked from jgoodall/calendar.sh
Created October 4, 2013 07:24
Show Gist options
  • Save tzarskyz/6822199 to your computer and use it in GitHub Desktop.
Save tzarskyz/6822199 to your computer and use it in GitHub Desktop.
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment