dotfiles

regexghost dotfiles and scripts
git clone https://git.regexghost.com/dotfiles.git
Log | Files | Refs | README

calendar.sh (723B)


      1 #!/bin/sh
      2 
      3 MAGENTA_COLOUR='\033[0;35m\033[1m'
      4 RED_COLOUR='\033[0;34m\033[1m'
      5 BLUE_COLOUR='\033[0;36m\033[1m'
      6 RESET_COLOUR='\033[0m'
      7 
      8 suffix () {
      9 	if [ "$1" = "1" ] || [ "$1" = "21" ] || [ "$1" = "31" ]; then
     10 		echo "st"
     11 	elif [ "$1" = "2" ] || [ "$1" = "22" ]; then
     12 		echo "nd"
     13 	elif [ "$1" = "3" ] || [ "$1" = "23" ]; then
     14 		echo "rd"
     15 	else
     16 		echo "th"
     17 	fi
     18 }
     19 
     20 # Unbuffer keeps the little box around the current day, sed deletes empty line at the end
     21 unbuffer cal -w -n 3 "$@" | sed '/^ *$/d'
     22 
     23 day="$(date +'%A')"
     24 date="$(date +'%d')"
     25 week="$(date +'%V')"
     26 
     27 echo "${RED_COLOUR}Day:${RESET_COLOUR}  ${day}"
     28 echo "${BLUE_COLOUR}Date:${RESET_COLOUR} ${date}$(suffix $date)"
     29 echo "${MAGENTA_COLOUR}Week:${RESET_COLOUR} ${week}"