summaryrefslogtreecommitdiffstats
path: root/.local/bin/milieage
blob: ed1bea7523d7b098ab8cd5b497c26f12c005dce4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 "\n# %s %s %s %s %s" "$datestamp" "$current" "$previous" "$miles" "$banked" >>"$0"

exit