Last active
December 12, 2023 16:09
-
-
Save RedL0tus/d27168dc7fbd207ee7038d6363464592 to your computer and use it in GitHub Desktop.
\\\ Year Progress ///
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
# Year Progress | |
export LENGTH=20; | |
function GET_PERCENTAGE { | |
local CURRENT_YEAR=$(date +%Y); | |
if [ $((CURRENT_YEAR % 400)) -eq 0 ]; then | |
local TOTAL_DAYS=366; | |
elif [ $((CURRENT_YEAR % 100)) -eq 0 ]; then | |
local TOTAL_DAYS=365; | |
elif [ $((CURRENT_YEAR % 4)) -eq 0 ]; then | |
local TOTAL_DAYS=366; | |
else | |
local TOTAL_DAYS=365; | |
fi | |
CURRENT_DAY=$(echo "$(date +%j) + 0" | bc) | |
echo $((200*$CURRENT_DAY/$TOTAL_DAYS % 2 + 100*$CURRENT_DAY/$TOTAL_DAYS)); | |
} | |
function DISPLAY { | |
local PERCENTAGE=$(GET_PERCENTAGE); | |
local FILLED=$(($LENGTH*$PERCENTAGE/100)); | |
local BLANK=$(($LENGTH-$FILLED)); | |
for ((i=0;i<$FILLED;i++)) { | |
echo -ne "▓"; | |
} | |
for ((i=0;i<$BLANK;i++)) { | |
echo -ne "░"; | |
} | |
echo -ne " $PERCENTAGE %\n"; | |
} | |
DISPLAY; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment