:
#!sh
# today
#
# Display calendar for current month with current day in standout mode.
# Also display pasted on calendar for next month if day of month exceeds 23.
#
# If termput exists with termcap
#b=`termput so` # b is standout mode
#e=`termput se` # e is standout end mode
# For terminfo
b=`tput smso` # b is standout mode
e=`tput rmso` # e is standout end mode
# Unique name for two temporary files
tmpf1=/tmp/1$$
tmpf2=/tmp/2$$
echo ' '
date
echo ' '
# set the shell arguments
set `date '+ %m 19%y %d'`
year=$2
tmp=$3 # $3 is day of the month
# if day is less than 10, then strip off the leading zero
if test $3 -lt 10
then
tmp=" `echo $3 | sed -e 's/0//'`"
fi
# if day is 19th then add trailing space so it will not confuse the 19 of 19??
if [ "$tmp" = "19" ]; then
tmp=`echo "${tmp} "`
elif [ "$tmp" = "1" ]; then
tmp=`echo "${tmp} "`
fi
# Problem with date "1" at the end of a line.
# Run cal prog and highlight current day; $1 is month $2 is current year
# $3 is day of the month, ${tmp} a convenient representation thereof.
#
if test $3 -gt 23
then
cal $1 $year | sed "s/ ${tmp} / $b${tmp}$e /" |\
sed "s/^${tmp} /$b${tmp}$e /" |\
sed "s/ ${tmp}$/ $b${tmp}$e/" > $tmpf1
# Account for break across years
nextmonth=`expr $1 + 1`
if [ $nextmonth -eq 13 ]; then
nextmonth=1
year=`expr $year + 1`
fi
cal $nextmonth $year > $tmpf2
paste $tmpf1 $tmpf2 | sed "s/$year/$year /" |\
sed "s/29 /29 /" |\
sed "s/30 /30 /" |\
sed "s/31 /31 /" |\
sed "s/ / /"
rm -f $tmpf1 $tmpf2
else
cal $1 $year | sed "s/ ${tmp} / $b${tmp}$e /" |\
sed "s/^${tmp} /$b${tmp}$e /" |\
sed "s/ ${tmp}/ $b${tmp}$e/" |\
sed "s/ ${tmp}$/ $b${tmp}$e/"
fi
exit 0
Return to Home Page
Return to Metayoga Page
Return to shell Page
The URL for this document is:
http://graham.main.nc.us/~bhammel/graham/SHELL/today.html
Created: 1997
Last Updated: May 28, 2000
Email me, Bill Hammel at
bhammel@graham.main.nc.us
READ WARNING BEFORE SENDING E-MAIL