====== Login Banner with Calendar ====== A small shell script that uses cal and other builtin info to display a nicely cached (hence fast) color calendar banner from your .bashrc. The calendar data is in hungarian. #!/bin/bash #bash banner script by mcree ################################# # CACHE HIT f=~/.banner.tmp stat=`stat -c %y $f 2> /dev/null | cut -f 1 -d' ' ` date=`date +%Y-%m-%d` if [ "$stat" = "$date" ]; then cat $f return fi ################################# # DATA honapok=`cat < $f cal=`cal -f 1 2>/dev/null` if [ -z "$cal" ]; then cal=`cal -m 2>/dev/null` fi if [ -z "$cal" ]; then cal=`cal 2>/dev/null` fi echo -e "$C_MAGENTA$b$C_GRAY h k sz cs p sz v" >> "$f" callines=`echo -e "$cal" -f 1 | wc -l` callines=`expr $callines - 2` day="1" line="0" echo -e "$cal" | tail -n$callines | tr ' ' '#' | while read x; do line=`expr $line + 1` if [ $x ]; then week=`date -d "$Y-$m-$day +1 day" +"%V"` echo -ne "$C_DCYAN$week$C_RESET " >>$f for i in `seq 1 3 20`; do ii=`expr $i + 1` day=`echo $x | cut -b$i-$ii | tr -d '#'` if [ $day ]; then dow=`date -d "$Y-$m-$day" +"%u"` if expr $day = $d > /dev/null; then printf " $B_RED%2i$C_RESET" $day >>$f else if [ $dow = "6" -o $dow = "7" ]; then printf " $C_DRED%2i$C_RESET" $day >>$f else printf " $C_GRAY%2i$C_RESET" $day >>$f fi fi else echo -ne " " >>$f fi done echo -ne " $C_GRAY|$C_RESET " >> $f case "$line" in "1") echo -ne " $C_DYELLOW$Y-$m-$d, $C_YELLOW$A" >> $f ;; "2") echo -ne " $C_GRAY$B: $C_BLUE$todaymonth" >> $f ;; "3") echo -ne " $C_WHITE$todaynevnap;$C_GREY $tomorrownevnap;$C_DGREY $ttomorrownevnap;" >> $f ;; "4") echo -ne " $C_DBLUE$todayvilagnap" >> $f ;; esac echo -e "$C_RESET" >>$f fi done cat $f {{tag>util calendar login bash}} ~~LINKBACK~~