Skip to content

Instantly share code, notes, and snippets.

@RedL0tus
Last active December 12, 2023 16:09
Show Gist options
  • Save RedL0tus/d27168dc7fbd207ee7038d6363464592 to your computer and use it in GitHub Desktop.
Save RedL0tus/d27168dc7fbd207ee7038d6363464592 to your computer and use it in GitHub Desktop.
\\\ Year Progress ///
# 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