Created
November 12, 2012 18:35
-
-
Save jgoodall/4061048 to your computer and use it in GitHub Desktop.
shell script to print a calendar to the screen, highlighting today (geektool)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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
Came up with the following recipe for a colorized calendar in geektool.