Skip to content

Instantly share code, notes, and snippets.

@ProxyAi
Created May 9, 2023 12:50
Show Gist options
  • Save ProxyAi/2ddc1761b41ffd6753ed2f5d953c20f1 to your computer and use it in GitHub Desktop.
Save ProxyAi/2ddc1761b41ffd6753ed2f5d953c20f1 to your computer and use it in GitHub Desktop.

Revisions

  1. ProxyAi created this gist May 9, 2023.
    33 changes: 33 additions & 0 deletions terminal_calendar.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    #!/bin/bash

    # Get current year and month
    year=$(date +%Y)
    month=$(date +%m)

    # Print month and year
    echo "$(date +%B\ %Y)"

    # Print the days of the week
    echo "Su Mo Tu We Th Fr Sa"

    # Get the first day of the month
    first_day=$(date -d "$year-$month-01" +%w)

    # Create the calendar
    for ((i=0; i<$first_day; i++)); do
    printf " "
    done
    for ((day=1; day<=31; day++)); do
    if (( day < 10 )); then
    printf " "
    fi
    if (( day == $(date +%e) && month == $(date +%m) )); then
    printf "\e[7m%s\e[0m " $day
    else
    printf "%s " $day
    fi
    if (( $(($day+$first_day)) % 7 == 0 )); then
    printf "\n"
    fi
    done
    printf "\n"