From 59d67aeb8144436f0df3fcdc8abc9f2a5e86bfce Mon Sep 17 00:00:00 2001 From: Peter Date: Fri, 31 May 2024 16:39:10 +0100 Subject: Add mileage script --- .local/bin/milieage | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 .local/bin/milieage (limited to '.local') diff --git a/.local/bin/milieage b/.local/bin/milieage new file mode 100755 index 0000000..c6831cd --- /dev/null +++ b/.local/bin/milieage @@ -0,0 +1,22 @@ +#!/bin/bash + +old_current=$(tail -1 "$0" | awk '{print $3}') +old_previous=$(tail -1 "$0" | awk '{print $4}') +old_miles=$(tail -1 "$0" | awk '{print $5}') + +read -rp "Enter current car odometer ($old_current): " current +if [ -z "${current}" ]; then current="$old_current"; fi +read -rp "Enter previous month odometer ($old_previous): " previous +if [ -z "${previous}" ]; then current="$old_previous"; fi +read -rp "Enter business miles for month ($old_miles): " miles +if [ -z "${miles}" ]; then current="$old_miles"; fi + +banked="$(echo "($miles + $previous) - $current" | bc)" +lie_miles="$(shuf -i 5-15 -n 1)" +lie="$(echo "$previous" + "$miles" + "$lie_miles" | bc)" +printf "\nYou have %s miles in the bank.\nEnter %s as your month end." "$banked" "$lie" + +datestamp=$(date +"%Y-%m-%dT%H:%M:%S%z") +printf "# %s %s %s %s %s" "$datestamp" "$current" "$previous" "$miles" "$banked">> "$0" + +exit -- cgit v1.2.3